diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-22 18:53:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-22 18:53:34 +0000 |
commit | 8f88a01462641cbf930b3c43b780565d0fb7d37e (patch) | |
tree | e211588c29e6ce6d16fbbfd33d8cda63237c2e6e /docs/sqlglot/parser.html | |
parent | Releasing debian version 16.2.1-1. (diff) | |
download | sqlglot-8f88a01462641cbf930b3c43b780565d0fb7d37e.tar.xz sqlglot-8f88a01462641cbf930b3c43b780565d0fb7d37e.zip |
Merging upstream version 16.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docs/sqlglot/parser.html')
-rw-r--r-- | docs/sqlglot/parser.html | 16126 |
1 files changed, 8071 insertions, 8055 deletions
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> |