diff options
Diffstat (limited to 'docs/sqlglot/dialects/bigquery.html')
-rw-r--r-- | docs/sqlglot/dialects/bigquery.html | 3975 |
1 files changed, 2001 insertions, 1974 deletions
diff --git a/docs/sqlglot/dialects/bigquery.html b/docs/sqlglot/dialects/bigquery.html index 2e8f5b1..3e8fedb 100644 --- a/docs/sqlglot/dialects/bigquery.html +++ b/docs/sqlglot/dialects/bigquery.html @@ -160,6 +160,9 @@ <a class="variable" href="#BigQuery.Parser.NULL_TOKENS">NULL_TOKENS</a> </li> <li> + <a class="variable" href="#BigQuery.Parser.DASHED_TABLE_PART_FOLLOW_TOKENS">DASHED_TABLE_PART_FOLLOW_TOKENS</a> + </li> + <li> <a class="variable" href="#BigQuery.Parser.STATEMENT_PARSERS">STATEMENT_PARSERS</a> </li> <li> @@ -1010,637 +1013,641 @@ </span><span id="L-589"><a href="#L-589"><span class="linenos"> 589</span></a> </span><span id="L-590"><a href="#L-590"><span class="linenos"> 590</span></a> <span class="n">NULL_TOKENS</span> <span class="o">=</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">UNKNOWN</span><span class="p">}</span> </span><span id="L-591"><a href="#L-591"><span class="linenos"> 591</span></a> -</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-593"><a href="#L-593"><span class="linenos"> 593</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> -</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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-595"><a href="#L-595"><span class="linenos"> 595</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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-596"><a href="#L-596"><span class="linenos"> 596</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">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">_parse_for_in</span><span class="p">(),</span> -</span><span id="L-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="p">}</span> -</span><span id="L-598"><a href="#L-598"><span class="linenos"> 598</span></a> -</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="n">BRACKET_OFFSETS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> -</span><span id="L-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="s2">"ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> -</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> <span class="s2">"SAFE_OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="s2">"SAFE_ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> <span class="p">}</span> -</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> -</span><span id="L-606"><a href="#L-606"><span class="linenos"> 606</span></a> <span class="k">def</span> <span class="nf">_parse_for_in</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">:</span> -</span><span id="L-607"><a href="#L-607"><span class="linenos"> 607</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">()</span> -</span><span id="L-608"><a href="#L-608"><span class="linenos"> 608</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-609"><a href="#L-609"><span class="linenos"> 609</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span 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_statement</span><span class="p">())</span> -</span><span id="L-610"><a href="#L-610"><span class="linenos"> 610</span></a> -</span><span id="L-611"><a href="#L-611"><span class="linenos"> 611</span></a> <span class="k">def</span> <span class="nf">_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-612"><a href="#L-612"><span class="linenos"> 612</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> -</span><span id="L-614"><a href="#L-614"><span class="linenos"> 614</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> -</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> -</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="L-618"><a href="#L-618"><span class="linenos"> 618</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-619"><a href="#L-619"><span class="linenos"> 619</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</span><span class="p">()</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="o">!=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">:</span> -</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-621"><a href="#L-621"><span class="linenos"> 621</span></a> <span class="n">text</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-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="n">table_name</span> <span class="o">+=</span> <span class="n">text</span> -</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</span></a> -</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> -</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</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">Literal</span><span class="p">):</span> -</span><span id="L-626"><a href="#L-626"><span class="linenos"> 626</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="n">DASHED_TABLE_PART_FOLLOW_TOKENS</span> <span class="o">=</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">L_PAREN</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-593"><a href="#L-593"><span class="linenos"> 593</span></a> +</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-595"><a href="#L-595"><span class="linenos"> 595</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> +</span><span id="L-596"><a href="#L-596"><span class="linenos"> 596</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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-598"><a href="#L-598"><span class="linenos"> 598</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">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">_parse_for_in</span><span class="p">(),</span> +</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="p">}</span> +</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> +</span><span id="L-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="n">BRACKET_OFFSETS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> +</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="s2">"ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> +</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> <span class="s2">"SAFE_OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> <span class="s2">"SAFE_ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">True</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><span id="L-608"><a href="#L-608"><span class="linenos"> 608</span></a> <span class="k">def</span> <span class="nf">_parse_for_in</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">:</span> +</span><span id="L-609"><a href="#L-609"><span class="linenos"> 609</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">()</span> +</span><span id="L-610"><a href="#L-610"><span class="linenos"> 610</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-611"><a href="#L-611"><span class="linenos"> 611</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span 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_statement</span><span class="p">())</span> +</span><span id="L-612"><a href="#L-612"><span class="linenos"> 612</span></a> +</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> <span class="k">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-614"><a href="#L-614"><span class="linenos"> 614</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> +</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> +</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</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-618"><a href="#L-618"><span class="linenos"> 618</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-619"><a href="#L-619"><span class="linenos"> 619</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</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-621"><a href="#L-621"><span class="linenos"> 621</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</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_set</span><span class="p">(</span> +</span><span id="L-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">DASHED_TABLE_PART_FOLLOW_TOKENS</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span> +</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</span></a> <span class="p">):</span> +</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</span></a> +</span><span id="L-626"><a href="#L-626"><span class="linenos"> 626</span></a> <span class="n">table_name</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-627"><a href="#L-627"><span class="linenos"> 627</span></a> -</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</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 class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="L-629"><a href="#L-629"><span class="linenos"> 629</span></a> <span class="n">table_name</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-630"><a href="#L-630"><span class="linenos"> 630</span></a> -</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</span></a> -</span><span id="L-633"><a href="#L-633"><span class="linenos"> 633</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> +</span><span id="L-629"><a href="#L-629"><span class="linenos"> 629</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">Literal</span><span class="p">):</span> +</span><span id="L-630"><a href="#L-630"><span class="linenos"> 630</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> +</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</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 class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="L-633"><a href="#L-633"><span class="linenos"> 633</span></a> <span class="n">table_name</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-634"><a href="#L-634"><span class="linenos"> 634</span></a> -</span><span id="L-635"><a href="#L-635"><span class="linenos"> 635</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span> -</span><span id="L-636"><a href="#L-636"><span class="linenos"> 636</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">is_db_reference</span><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">wildcard</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span> -</span><span id="L-639"><a href="#L-639"><span class="linenos"> 639</span></a> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">,</span> <span class="n">is_db_reference</span><span class="o">=</span><span class="n">is_db_reference</span><span class="p">,</span> <span class="n">wildcard</span><span class="o">=</span><span class="kc">True</span> -</span><span id="L-640"><a href="#L-640"><span class="linenos"> 640</span></a> <span class="p">)</span> -</span><span id="L-641"><a href="#L-641"><span class="linenos"> 641</span></a> -</span><span id="L-642"><a href="#L-642"><span class="linenos"> 642</span></a> <span class="c1"># proj-1.db.tbl -- `1.` is tokenized as a float so we need to unravel it here</span> -</span><span id="L-643"><a href="#L-643"><span class="linenos"> 643</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">catalog</span><span class="p">:</span> -</span><span id="L-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="k">if</span> <span class="n">table</span><span class="o">.</span><span class="n">db</span><span class="p">:</span> -</span><span id="L-645"><a href="#L-645"><span class="linenos"> 645</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">db</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-646"><a href="#L-646"><span class="linenos"> 646</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"db"</span><span class="p">]</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> -</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> -</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> -</span><span id="L-649"><a href="#L-649"><span class="linenos"> 649</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-650"><a href="#L-650"><span class="linenos"> 650</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">name</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-651"><a href="#L-651"><span class="linenos"> 651</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> -</span><span id="L-652"><a href="#L-652"><span class="linenos"> 652</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> -</span><span id="L-653"><a href="#L-653"><span class="linenos"> 653</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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-654"><a href="#L-654"><span class="linenos"> 654</span></a> -</span><span id="L-655"><a href="#L-655"><span class="linenos"> 655</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">):</span> -</span><span id="L-656"><a href="#L-656"><span class="linenos"> 656</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-657"><a href="#L-657"><span class="linenos"> 657</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-658"><a href="#L-658"><span class="linenos"> 658</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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-659"><a href="#L-659"><span class="linenos"> 659</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> -</span><span id="L-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><span id="L-662"><a href="#L-662"><span class="linenos"> 662</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> -</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> -</span><span id="L-665"><a href="#L-665"><span class="linenos"> 665</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span> -</span><span id="L-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">)</span> -</span><span id="L-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="p">)</span> -</span><span id="L-668"><a href="#L-668"><span class="linenos"> 668</span></a> <span class="n">table</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_table"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-670"><a href="#L-670"><span class="linenos"> 670</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-671"><a href="#L-671"><span class="linenos"> 671</span></a> -</span><span id="L-672"><a href="#L-672"><span class="linenos"> 672</span></a> <span class="c1"># The `INFORMATION_SCHEMA` views in BigQuery need to be qualified by a region or</span> -</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="c1"># dataset, so if the project identifier is omitted we need to fix the ast so that</span> -</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="c1"># the `INFORMATION_SCHEMA.X` bit is represented as a single (quoted) Identifier.</span> -</span><span id="L-675"><a href="#L-675"><span class="linenos"> 675</span></a> <span class="c1"># Otherwise, we wouldn't correctly qualify a `Table` node that references these</span> -</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="c1"># views, because it would seem like the "catalog" part is set, when it'd actually</span> -</span><span id="L-677"><a href="#L-677"><span class="linenos"> 677</span></a> <span class="c1"># be the region/dataset. Merging the two identifiers into a single one is done to</span> -</span><span id="L-678"><a href="#L-678"><span class="linenos"> 678</span></a> <span class="c1"># avoid producing a 4-part Table reference, which would cause issues in the schema</span> -</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</span></a> <span class="c1"># module, when there are 3-part table names mixed with information schema views.</span> -</span><span id="L-680"><a href="#L-680"><span class="linenos"> 680</span></a> <span class="c1">#</span> -</span><span id="L-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="c1"># See: https://cloud.google.com/bigquery/docs/information-schema-intro#syntax</span> -</span><span id="L-682"><a href="#L-682"><span class="linenos"> 682</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span> -</span><span id="L-683"><a href="#L-683"><span class="linenos"> 683</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">table_parts</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"INFORMATION_SCHEMA"</span><span class="p">:</span> -</span><span id="L-684"><a href="#L-684"><span class="linenos"> 684</span></a> <span class="c1"># We need to alias the table here to avoid breaking existing qualified columns.</span> -</span><span id="L-685"><a href="#L-685"><span class="linenos"> 685</span></a> <span class="c1"># This is expected to be safe, because if there's an actual alias coming up in</span> -</span><span id="L-686"><a href="#L-686"><span class="linenos"> 686</span></a> <span class="c1"># the token stream, it will overwrite this one. If there isn't one, we are only</span> -</span><span id="L-687"><a href="#L-687"><span class="linenos"> 687</span></a> <span class="c1"># exposing the name that can be used to reference the view explicitly (a no-op).</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">alias_</span><span class="p">(</span> -</span><span id="L-689"><a href="#L-689"><span class="linenos"> 689</span></a> <span class="n">table</span><span class="p">,</span> -</span><span id="L-690"><a href="#L-690"><span class="linenos"> 690</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">Identifier</span><span class="p">,</span> <span class="n">alias</span> <span class="ow">or</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]),</span> -</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="L-692"><a href="#L-692"><span class="linenos"> 692</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-693"><a href="#L-693"><span class="linenos"> 693</span></a> <span class="p">)</span> -</span><span id="L-694"><a href="#L-694"><span class="linenos"> 694</span></a> -</span><span id="L-695"><a href="#L-695"><span class="linenos"> 695</span></a> <span class="n">info_schema_view</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">table_parts</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">name</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-696"><a href="#L-696"><span class="linenos"> 696</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">info_schema_view</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-697"><a href="#L-697"><span class="linenos"> 697</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">))</span> -</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">4</span><span class="p">))</span> -</span><span id="L-699"><a href="#L-699"><span class="linenos"> 699</span></a> -</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</span></a> <span class="k">return</span> <span class="n">table</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="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-703"><a href="#L-703"><span class="linenos"> 703</span></a> <span class="n">column</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="L-704"><a href="#L-704"><span class="linenos"> 704</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span> -</span><span id="L-706"><a href="#L-706"><span class="linenos"> 706</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">):</span> -</span><span id="L-707"><a href="#L-707"><span class="linenos"> 707</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> -</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="p">)</span> -</span><span id="L-711"><a href="#L-711"><span class="linenos"> 711</span></a> -</span><span id="L-712"><a href="#L-712"><span class="linenos"> 712</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-713"><a href="#L-713"><span class="linenos"> 713</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</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">column</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">table</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><span id="L-716"><a href="#L-716"><span class="linenos"> 716</span></a> <span class="n">column</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_column"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</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="k">return</span> <span class="n">column</span> -</span><span id="L-719"><a href="#L-719"><span class="linenos"> 719</span></a> -</span><span id="L-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-721"><a href="#L-721"><span class="linenos"> 721</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObject</span><span class="p">:</span> <span class="o">...</span> -</span><span id="L-722"><a href="#L-722"><span class="linenos"> 722</span></a> -</span><span id="L-723"><a href="#L-723"><span class="linenos"> 723</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-724"><a href="#L-724"><span class="linenos"> 724</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObjectAgg</span><span class="p">:</span> <span class="o">...</span> -</span><span id="L-725"><a href="#L-725"><span class="linenos"> 725</span></a> -</span><span id="L-726"><a href="#L-726"><span class="linenos"> 726</span></a> <span class="k">def</span> <span class="nf">_parse_json_object</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">agg</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> -</span><span id="L-727"><a href="#L-727"><span class="linenos"> 727</span></a> <span class="n">json_object</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_json_object</span><span class="p">()</span> -</span><span id="L-728"><a href="#L-728"><span class="linenos"> 728</span></a> <span class="n">array_kv_pair</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">json_object</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-635"><a href="#L-635"><span class="linenos"> 635</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-636"><a href="#L-636"><span class="linenos"> 636</span></a> +</span><span id="L-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> +</span><span id="L-639"><a href="#L-639"><span class="linenos"> 639</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span> +</span><span id="L-640"><a href="#L-640"><span class="linenos"> 640</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">is_db_reference</span><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">wildcard</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-641"><a href="#L-641"><span class="linenos"> 641</span></a> <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-642"><a href="#L-642"><span class="linenos"> 642</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span> +</span><span id="L-643"><a href="#L-643"><span class="linenos"> 643</span></a> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">,</span> <span class="n">is_db_reference</span><span class="o">=</span><span class="n">is_db_reference</span><span class="p">,</span> <span class="n">wildcard</span><span class="o">=</span><span class="kc">True</span> +</span><span id="L-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="p">)</span> +</span><span id="L-645"><a href="#L-645"><span class="linenos"> 645</span></a> +</span><span id="L-646"><a href="#L-646"><span class="linenos"> 646</span></a> <span class="c1"># proj-1.db.tbl -- `1.` is tokenized as a float so we need to unravel it here</span> +</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">catalog</span><span class="p">:</span> +</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <span class="k">if</span> <span class="n">table</span><span class="o">.</span><span class="n">db</span><span class="p">:</span> +</span><span id="L-649"><a href="#L-649"><span class="linenos"> 649</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">db</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-650"><a href="#L-650"><span class="linenos"> 650</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"db"</span><span class="p">]</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> +</span><span id="L-651"><a href="#L-651"><span class="linenos"> 651</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> +</span><span id="L-652"><a href="#L-652"><span class="linenos"> 652</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> +</span><span id="L-653"><a href="#L-653"><span class="linenos"> 653</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-654"><a href="#L-654"><span class="linenos"> 654</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">name</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-655"><a href="#L-655"><span class="linenos"> 655</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> +</span><span id="L-656"><a href="#L-656"><span class="linenos"> 656</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> +</span><span id="L-657"><a href="#L-657"><span class="linenos"> 657</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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-658"><a href="#L-658"><span class="linenos"> 658</span></a> +</span><span id="L-659"><a href="#L-659"><span class="linenos"> 659</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">):</span> +</span><span id="L-660"><a href="#L-660"><span class="linenos"> 660</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-661"><a href="#L-661"><span class="linenos"> 661</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-662"><a href="#L-662"><span class="linenos"> 662</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> +</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> <span class="p">)</span> +</span><span id="L-665"><a href="#L-665"><span class="linenos"> 665</span></a> +</span><span id="L-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> +</span><span id="L-668"><a href="#L-668"><span class="linenos"> 668</span></a> +</span><span id="L-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span> +</span><span id="L-670"><a href="#L-670"><span class="linenos"> 670</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">)</span> +</span><span id="L-671"><a href="#L-671"><span class="linenos"> 671</span></a> <span class="p">)</span> +</span><span id="L-672"><a href="#L-672"><span class="linenos"> 672</span></a> <span class="n">table</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_table"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-675"><a href="#L-675"><span class="linenos"> 675</span></a> +</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="c1"># The `INFORMATION_SCHEMA` views in BigQuery need to be qualified by a region or</span> +</span><span id="L-677"><a href="#L-677"><span class="linenos"> 677</span></a> <span class="c1"># dataset, so if the project identifier is omitted we need to fix the ast so that</span> +</span><span id="L-678"><a href="#L-678"><span class="linenos"> 678</span></a> <span class="c1"># the `INFORMATION_SCHEMA.X` bit is represented as a single (quoted) Identifier.</span> +</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</span></a> <span class="c1"># Otherwise, we wouldn't correctly qualify a `Table` node that references these</span> +</span><span id="L-680"><a href="#L-680"><span class="linenos"> 680</span></a> <span class="c1"># views, because it would seem like the "catalog" part is set, when it'd actually</span> +</span><span id="L-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="c1"># be the region/dataset. Merging the two identifiers into a single one is done to</span> +</span><span id="L-682"><a href="#L-682"><span class="linenos"> 682</span></a> <span class="c1"># avoid producing a 4-part Table reference, which would cause issues in the schema</span> +</span><span id="L-683"><a href="#L-683"><span class="linenos"> 683</span></a> <span class="c1"># module, when there are 3-part table names mixed with information schema views.</span> +</span><span id="L-684"><a href="#L-684"><span class="linenos"> 684</span></a> <span class="c1">#</span> +</span><span id="L-685"><a href="#L-685"><span class="linenos"> 685</span></a> <span class="c1"># See: https://cloud.google.com/bigquery/docs/information-schema-intro#syntax</span> +</span><span id="L-686"><a href="#L-686"><span class="linenos"> 686</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span> +</span><span id="L-687"><a href="#L-687"><span class="linenos"> 687</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">table_parts</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"INFORMATION_SCHEMA"</span><span class="p">:</span> +</span><span id="L-688"><a href="#L-688"><span class="linenos"> 688</span></a> <span class="c1"># We need to alias the table here to avoid breaking existing qualified columns.</span> +</span><span id="L-689"><a href="#L-689"><span class="linenos"> 689</span></a> <span class="c1"># This is expected to be safe, because if there's an actual alias coming up in</span> +</span><span id="L-690"><a href="#L-690"><span class="linenos"> 690</span></a> <span class="c1"># the token stream, it will overwrite this one. If there isn't one, we are only</span> +</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="c1"># exposing the name that can be used to reference the view explicitly (a no-op).</span> +</span><span id="L-692"><a href="#L-692"><span class="linenos"> 692</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span> +</span><span id="L-693"><a href="#L-693"><span class="linenos"> 693</span></a> <span class="n">table</span><span class="p">,</span> +</span><span id="L-694"><a href="#L-694"><span class="linenos"> 694</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">Identifier</span><span class="p">,</span> <span class="n">alias</span> <span class="ow">or</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]),</span> +</span><span id="L-695"><a href="#L-695"><span class="linenos"> 695</span></a> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="L-696"><a href="#L-696"><span class="linenos"> 696</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-697"><a href="#L-697"><span class="linenos"> 697</span></a> <span class="p">)</span> +</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> +</span><span id="L-699"><a href="#L-699"><span class="linenos"> 699</span></a> <span class="n">info_schema_view</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">table_parts</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">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">info_schema_view</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-701"><a href="#L-701"><span class="linenos"> 701</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">))</span> +</span><span id="L-702"><a href="#L-702"><span class="linenos"> 702</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">4</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="k">return</span> <span class="n">table</span> +</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> +</span><span id="L-706"><a href="#L-706"><span class="linenos"> 706</span></a> <span class="k">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-707"><a href="#L-707"><span class="linenos"> 707</span></a> <span class="n">column</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="L-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span> +</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">):</span> +</span><span id="L-711"><a href="#L-711"><span class="linenos"> 711</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-712"><a href="#L-712"><span class="linenos"> 712</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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-713"><a href="#L-713"><span class="linenos"> 713</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">4</span><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="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-717"><a href="#L-717"><span class="linenos"> 717</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> +</span><span id="L-718"><a href="#L-718"><span class="linenos"> 718</span></a> +</span><span id="L-719"><a href="#L-719"><span class="linenos"> 719</span></a> <span class="n">column</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">table</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><span id="L-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="n">column</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_column"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-721"><a href="#L-721"><span class="linenos"> 721</span></a> +</span><span id="L-722"><a href="#L-722"><span class="linenos"> 722</span></a> <span class="k">return</span> <span class="n">column</span> +</span><span id="L-723"><a href="#L-723"><span class="linenos"> 723</span></a> +</span><span id="L-724"><a href="#L-724"><span class="linenos"> 724</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-725"><a href="#L-725"><span class="linenos"> 725</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObject</span><span class="p">:</span> <span class="o">...</span> +</span><span id="L-726"><a href="#L-726"><span class="linenos"> 726</span></a> +</span><span id="L-727"><a href="#L-727"><span class="linenos"> 727</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-728"><a href="#L-728"><span class="linenos"> 728</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObjectAgg</span><span class="p">:</span> <span class="o">...</span> </span><span id="L-729"><a href="#L-729"><span class="linenos"> 729</span></a> -</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</span></a> <span class="c1"># Converts BQ's "signature 2" of JSON_OBJECT into SQLGlot's canonical representation</span> -</span><span id="L-731"><a href="#L-731"><span class="linenos"> 731</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#json_object_signature2</span> -</span><span id="L-732"><a href="#L-732"><span class="linenos"> 732</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-733"><a href="#L-733"><span class="linenos"> 733</span></a> <span class="n">array_kv_pair</span> -</span><span id="L-734"><a href="#L-734"><span class="linenos"> 734</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> -</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span 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><span id="L-736"><a href="#L-736"><span class="linenos"> 736</span></a> <span class="p">):</span> -</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> <span class="n">values</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> -</span><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="n">json_object</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="L-742"><a href="#L-742"><span class="linenos"> 742</span></a> <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">k</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">values</span><span class="p">)],</span> -</span><span id="L-743"><a href="#L-743"><span class="linenos"> 743</span></a> <span class="p">)</span> -</span><span id="L-744"><a href="#L-744"><span class="linenos"> 744</span></a> -</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> <span class="k">return</span> <span class="n">json_object</span> -</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> -</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> -</span><span id="L-748"><a href="#L-748"><span class="linenos"> 748</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-749"><a href="#L-749"><span class="linenos"> 749</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-750"><a href="#L-750"><span class="linenos"> 750</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-751"><a href="#L-751"><span class="linenos"> 751</span></a> -</span><span id="L-752"><a href="#L-752"><span class="linenos"> 752</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">is</span> <span class="n">bracket</span><span class="p">:</span> -</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</span></a> <span class="k">return</span> <span class="n">bracket</span> -</span><span id="L-754"><a href="#L-754"><span class="linenos"> 754</span></a> -</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> -</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">bracket</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-757"><a href="#L-757"><span class="linenos"> 757</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</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="n">agg</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> +</span><span id="L-731"><a href="#L-731"><span class="linenos"> 731</span></a> <span class="n">json_object</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_json_object</span><span class="p">()</span> +</span><span id="L-732"><a href="#L-732"><span class="linenos"> 732</span></a> <span class="n">array_kv_pair</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">json_object</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-733"><a href="#L-733"><span class="linenos"> 733</span></a> +</span><span id="L-734"><a href="#L-734"><span class="linenos"> 734</span></a> <span class="c1"># Converts BQ's "signature 2" of JSON_OBJECT into SQLGlot's canonical representation</span> +</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#json_object_signature2</span> +</span><span id="L-736"><a href="#L-736"><span class="linenos"> 736</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> <span class="n">array_kv_pair</span> +</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> +</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span 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><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="p">):</span> +</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-742"><a href="#L-742"><span class="linenos"> 742</span></a> <span class="n">values</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-743"><a href="#L-743"><span class="linenos"> 743</span></a> +</span><span id="L-744"><a href="#L-744"><span class="linenos"> 744</span></a> <span class="n">json_object</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> <span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> <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">k</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">values</span><span class="p">)],</span> +</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="p">)</span> +</span><span id="L-748"><a href="#L-748"><span class="linenos"> 748</span></a> +</span><span id="L-749"><a href="#L-749"><span class="linenos"> 749</span></a> <span class="k">return</span> <span class="n">json_object</span> +</span><span id="L-750"><a href="#L-750"><span class="linenos"> 750</span></a> +</span><span id="L-751"><a href="#L-751"><span class="linenos"> 751</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> +</span><span id="L-752"><a href="#L-752"><span class="linenos"> 752</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</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-754"><a href="#L-754"><span class="linenos"> 754</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> +</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">is</span> <span class="n">bracket</span><span class="p">:</span> +</span><span id="L-757"><a href="#L-757"><span class="linenos"> 757</span></a> <span class="k">return</span> <span class="n">bracket</span> </span><span id="L-758"><a href="#L-758"><span class="linenos"> 758</span></a> -</span><span id="L-759"><a href="#L-759"><span class="linenos"> 759</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">:</span> -</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> <span class="k">break</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">offset</span><span class="p">,</span> <span class="n">safe</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> -</span><span id="L-763"><a href="#L-763"><span class="linenos"> 763</span></a> <span class="n">bracket</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">offset</span><span class="p">)</span> -</span><span id="L-764"><a href="#L-764"><span class="linenos"> 764</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">,</span> <span class="n">safe</span><span class="p">)</span> -</span><span id="L-765"><a href="#L-765"><span class="linenos"> 765</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</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="k">return</span> <span class="n">bracket</span> -</span><span id="L-768"><a href="#L-768"><span class="linenos"> 768</span></a> -</span><span id="L-769"><a href="#L-769"><span class="linenos"> 769</span></a> <span class="k">def</span> <span class="nf">_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-770"><a href="#L-770"><span class="linenos"> 770</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</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="n">with_alias</span><span class="p">)</span> -</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> -</span><span id="L-772"><a href="#L-772"><span class="linenos"> 772</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="L-773"><a href="#L-773"><span class="linenos"> 773</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-774"><a href="#L-774"><span class="linenos"> 774</span></a> -</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">unnest</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-776"><a href="#L-776"><span class="linenos"> 776</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="p">:</span> -</span><span id="L-777"><a href="#L-777"><span class="linenos"> 777</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="L-759"><a href="#L-759"><span class="linenos"> 759</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> +</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">bracket</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-761"><a href="#L-761"><span class="linenos"> 761</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-762"><a href="#L-762"><span class="linenos"> 762</span></a> +</span><span id="L-763"><a href="#L-763"><span class="linenos"> 763</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">:</span> +</span><span id="L-764"><a href="#L-764"><span class="linenos"> 764</span></a> <span class="k">break</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">offset</span><span class="p">,</span> <span class="n">safe</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> +</span><span id="L-767"><a href="#L-767"><span class="linenos"> 767</span></a> <span class="n">bracket</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">offset</span><span class="p">)</span> +</span><span id="L-768"><a href="#L-768"><span class="linenos"> 768</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">,</span> <span class="n">safe</span><span class="p">)</span> +</span><span id="L-769"><a href="#L-769"><span class="linenos"> 769</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="L-770"><a href="#L-770"><span class="linenos"> 770</span></a> +</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="L-772"><a href="#L-772"><span class="linenos"> 772</span></a> +</span><span id="L-773"><a href="#L-773"><span class="linenos"> 773</span></a> <span class="k">def</span> <span class="nf">_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-774"><a href="#L-774"><span class="linenos"> 774</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</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="n">with_alias</span><span class="p">)</span> +</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</span></a> +</span><span id="L-776"><a href="#L-776"><span class="linenos"> 776</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="L-777"><a href="#L-777"><span class="linenos"> 777</span></a> <span class="k">return</span> <span class="kc">None</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">unnest_expr</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">unnest_expr</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="c1"># Unnesting a nested array (i.e array of structs) explodes the top-level struct fields,</span> -</span><span id="L-782"><a href="#L-782"><span class="linenos"> 782</span></a> <span class="c1"># in contrast to other dialects such as DuckDB which flattens only the array by default</span> -</span><span id="L-783"><a href="#L-783"><span class="linenos"> 783</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span> -</span><span id="L-784"><a href="#L-784"><span class="linenos"> 784</span></a> <span class="n">array_elem</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">)</span> -</span><span id="L-785"><a href="#L-785"><span class="linenos"> 785</span></a> <span class="k">for</span> <span class="n">array_elem</span> <span class="ow">in</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">_type</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-786"><a href="#L-786"><span class="linenos"> 786</span></a> <span class="p">):</span> -</span><span id="L-787"><a href="#L-787"><span class="linenos"> 787</span></a> <span class="n">unnest</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"explode_array"</span><span class="p">,</span> <span class="kc">True</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="k">return</span> <span class="n">unnest</span> -</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> -</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> <span class="k">def</span> <span class="nf">_parse_make_interval</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">:</span> -</span><span id="L-792"><a href="#L-792"><span class="linenos"> 792</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">()</span> -</span><span id="L-793"><a href="#L-793"><span class="linenos"> 793</span></a> -</span><span id="L-794"><a href="#L-794"><span class="linenos"> 794</span></a> <span class="k">for</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="n">expr</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> -</span><span id="L-795"><a href="#L-795"><span class="linenos"> 795</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> -</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> -</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> -</span><span id="L-798"><a href="#L-798"><span class="linenos"> 798</span></a> <span class="k">break</span> -</span><span id="L-799"><a href="#L-799"><span class="linenos"> 799</span></a> -</span><span id="L-800"><a href="#L-800"><span class="linenos"> 800</span></a> <span class="c1"># Non-named arguments are filled sequentially, (optionally) followed by named arguments</span> -</span><span id="L-801"><a href="#L-801"><span class="linenos"> 801</span></a> <span class="c1"># that can appear in any order e.g MAKE_INTERVAL(1, minute => 5, day => 2)</span> -</span><span id="L-802"><a href="#L-802"><span class="linenos"> 802</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">):</span> -</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> <span class="n">arg_key</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> -</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg_key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> -</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> -</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> <span class="bp">self</span><span 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-779"><a href="#L-779"><span class="linenos"> 779</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">unnest</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-780"><a href="#L-780"><span class="linenos"> 780</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="p">:</span> +</span><span id="L-781"><a href="#L-781"><span class="linenos"> 781</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="L-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">unnest_expr</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">unnest_expr</span><span class="p">)</span> +</span><span id="L-784"><a href="#L-784"><span class="linenos"> 784</span></a> +</span><span id="L-785"><a href="#L-785"><span class="linenos"> 785</span></a> <span class="c1"># Unnesting a nested array (i.e array of structs) explodes the top-level struct fields,</span> +</span><span id="L-786"><a href="#L-786"><span class="linenos"> 786</span></a> <span class="c1"># in contrast to other dialects such as DuckDB which flattens only the array by default</span> +</span><span id="L-787"><a href="#L-787"><span class="linenos"> 787</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span> +</span><span id="L-788"><a href="#L-788"><span class="linenos"> 788</span></a> <span class="n">array_elem</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">)</span> +</span><span id="L-789"><a href="#L-789"><span class="linenos"> 789</span></a> <span class="k">for</span> <span class="n">array_elem</span> <span class="ow">in</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">_type</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> <span class="p">):</span> +</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> <span class="n">unnest</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"explode_array"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> +</span><span id="L-792"><a href="#L-792"><span class="linenos"> 792</span></a> +</span><span id="L-793"><a href="#L-793"><span class="linenos"> 793</span></a> <span class="k">return</span> <span class="n">unnest</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="k">def</span> <span class="nf">_parse_make_interval</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">:</span> +</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">()</span> +</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</span></a> +</span><span id="L-798"><a href="#L-798"><span class="linenos"> 798</span></a> <span class="k">for</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="n">expr</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> +</span><span id="L-799"><a href="#L-799"><span class="linenos"> 799</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</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="k">if</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> +</span><span id="L-802"><a href="#L-802"><span class="linenos"> 802</span></a> <span class="k">break</span> +</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> +</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> <span class="c1"># Non-named arguments are filled sequentially, (optionally) followed by named arguments</span> +</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="c1"># that can appear in any order e.g MAKE_INTERVAL(1, minute => 5, day => 2)</span> +</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">):</span> +</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> <span class="n">arg_key</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> </span><span id="L-808"><a href="#L-808"><span class="linenos"> 808</span></a> -</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> <span class="k">return</span> <span class="n">expr</span> +</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg_key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> </span><span id="L-810"><a href="#L-810"><span class="linenos"> 810</span></a> -</span><span id="L-811"><a href="#L-811"><span class="linenos"> 811</span></a> <span class="k">def</span> <span class="nf">_parse_features_at_time</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">:</span> -</span><span id="L-812"><a href="#L-812"><span class="linenos"> 812</span></a> <span class="n">expr</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-813"><a href="#L-813"><span class="linenos"> 813</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">,</span> -</span><span id="L-814"><a href="#L-814"><span class="linenos"> 814</span></a> <span class="n">this</span><span class="o">=</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">TABLE</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-815"><a href="#L-815"><span class="linenos"> 815</span></a> <span class="ow">or</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-816"><a href="#L-816"><span class="linenos"> 816</span></a> <span class="p">)</span> -</span><span id="L-817"><a href="#L-817"><span class="linenos"> 817</span></a> -</span><span id="L-818"><a href="#L-818"><span class="linenos"> 818</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">COMMA</span><span class="p">):</span> -</span><span id="L-819"><a href="#L-819"><span class="linenos"> 819</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> -</span><span id="L-820"><a href="#L-820"><span class="linenos"> 820</span></a> -</span><span id="L-821"><a href="#L-821"><span class="linenos"> 821</span></a> <span class="c1"># Get the LHS of the Kwarg and set the arg to that value, e.g</span> -</span><span id="L-822"><a href="#L-822"><span class="linenos"> 822</span></a> <span class="c1"># "num_rows => 1" sets the expr's `num_rows` arg</span> -</span><span id="L-823"><a href="#L-823"><span class="linenos"> 823</span></a> <span class="k">if</span> <span class="n">arg</span><span class="p">:</span> -</span><span id="L-824"><a href="#L-824"><span class="linenos"> 824</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> -</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> -</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="k">return</span> <span class="n">expr</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">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="L-829"><a href="#L-829"><span class="linenos"> 829</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> <span class="n">UNNEST_WITH_ORDINALITY</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> <span class="n">COLLATE_IS_FUNC</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> <span class="n">SUPPORTS_TABLE_ALIAS_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="n">UNPIVOT_ALIASES_ARE_IDENTIFIERS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</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="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="n">JSON_PATH_SINGLE_QUOTE_ESCAPE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> -</span><span id="L-848"><a href="#L-848"><span class="linenos"> 848</span></a> <span class="n">HEX_FUNC</span> <span class="o">=</span> <span class="s2">"TO_HEX"</span> -</span><span id="L-849"><a href="#L-849"><span class="linenos"> 849</span></a> <span class="n">WITH_PROPERTIES_PREFIX</span> <span class="o">=</span> <span class="s2">"OPTIONS"</span> -</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="n">SUPPORTS_EXPLODING_PROJECTIONS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-851"><a href="#L-851"><span class="linenos"> 851</span></a> <span class="n">EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-852"><a href="#L-852"><span class="linenos"> 852</span></a> <span class="n">SUPPORTS_UNIX_SECONDS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-853"><a href="#L-853"><span class="linenos"> 853</span></a> -</span><span id="L-854"><a href="#L-854"><span class="linenos"> 854</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-855"><a href="#L-855"><span class="linenos"> 855</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> -</span><span id="L-857"><a href="#L-857"><span class="linenos"> 857</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> -</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> -</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> -</span><span id="L-860"><a href="#L-860"><span class="linenos"> 860</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">_array_contains_sql</span><span class="p">,</span> -</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">filter_array_using_unnest</span><span class="p">,</span> -</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_precision_parameterized_types</span><span class="p">]),</span> -</span><span id="L-863"><a href="#L-863"><span class="linenos"> 863</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> -</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</span></a> <span class="sa">f</span><span class="s2">"DEFAULT COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-865"><a href="#L-865"><span class="linenos"> 865</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> -</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-867"><a href="#L-867"><span class="linenos"> 867</span></a> <span class="p">),</span> -</span><span id="L-868"><a href="#L-868"><span class="linenos"> 868</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"COMMIT TRANSACTION"</span><span class="p">,</span> -</span><span id="L-869"><a href="#L-869"><span class="linenos"> 869</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COUNTIF"</span><span class="p">),</span> -</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> -</span><span id="L-871"><a href="#L-871"><span class="linenos"> 871</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_pushdown_cte_column_names</span><span class="p">]),</span> -</span><span id="L-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="L-873"><a href="#L-873"><span class="linenos"> 873</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-874"><a href="#L-874"><span class="linenos"> 874</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">unit_to_var</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a> <span class="p">),</span> -</span><span id="L-876"><a href="#L-876"><span class="linenos"> 876</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">),</span> -</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> -</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)</span> -</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a> <span class="p">),</span> -</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromTimeZone</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a> <span class="s2">"DATETIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)),</span> <span class="s2">"'UTC'"</span> -</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a> <span class="p">),</span> -</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GENERATE_ARRAY"</span><span class="p">),</span> -</span><span id="L-888"><a href="#L-888"><span class="linenos"> 888</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> -</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> -</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(</span><span class="n">false_value</span><span class="o">=</span><span class="s2">"NULL"</span><span class="p">),</span> -</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> -</span><span id="L-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Int64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"INT64"</span><span class="p">),</span> -</span><span id="L-894"><a href="#L-894"><span class="linenos"> 894</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> -</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractArray</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> -</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> -</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_JSON_STRING"</span><span class="p">),</span> -</span><span id="L-898"><a href="#L-898"><span class="linenos"> 898</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">_levenshtein_sql</span><span class="p">,</span> -</span><span id="L-899"><a href="#L-899"><span class="linenos"> 899</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> -</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">),</span> -</span><span id="L-902"><a href="#L-902"><span class="linenos"> 902</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> -</span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-907"><a href="#L-907"><span class="linenos"> 907</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">),</span> -</span><span id="L-909"><a href="#L-909"><span class="linenos"> 909</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"occurrence"</span><span class="p">),</span> -</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> <span class="p">),</span> -</span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtractAll</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> <span class="s2">"REGEXP_EXTRACT_ALL"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a> <span class="p">),</span> -</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="n">regexp_replace_sql</span><span class="p">,</span> -</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_CONTAINS"</span><span class="p">),</span> -</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> -</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"ROLLBACK TRANSACTION"</span><span class="p">,</span> -</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> <span class="p">[</span> -</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(),</span> -</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> -</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> <span class="n">_alias_ordered_group</span><span class="p">,</span> -</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">,</span> -</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</span></a> <span class="p">]</span> -</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</span></a> <span class="p">),</span> -</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SHA1"</span><span class="p">),</span> -</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA2</span><span class="p">:</span> <span class="n">sha256_sql</span><span class="p">,</span> -</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> -</span><span id="L-930"><a href="#L-930"><span class="linenos"> 930</span></a> <span class="s2">"DETERMINISTIC"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span> -</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</span></a> <span class="p">),</span> -</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">String</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING"</span><span class="p">),</span> -</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> -</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> -</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> -</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> -</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> -</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP_DIFF"</span><span class="p">),</span> -</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">,</span> -</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">_ts_or_ds_diff_sql</span><span class="p">,</span> -</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> -</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> -</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">),</span> -</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> -</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_DATE"</span><span class="p">),</span> -</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> -</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uuid</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"GENERATE_UUID()"</span><span class="p">,</span> -</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> -</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> -</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="p">}</span> -</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> -</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <span class="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> -</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> -</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> -</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> <span class="p">}</span> -</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> -</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> -</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> -</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">:</span> <span class="s2">"NUMERIC"</span><span class="p">,</span> -</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> -</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> -</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> -</span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UUID</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> -</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a> <span class="p">}</span> -</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a> -</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> <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="c1"># WINDOW comes after QUALIFY</span> -</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#window_clause</span> -</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> <span class="s2">"qualify"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"qualify"</span><span class="p">],</span> -</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> <span class="s2">"windows"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"windows"</span><span class="p">],</span> -</span><span id="L-1001"><a href="#L-1001"><span class="linenos">1001</span></a> <span class="p">}</span> -</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a> -</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> <span class="c1"># from: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords</span> -</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a> <span class="s2">"all"</span><span class="p">,</span> -</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a> <span class="s2">"and"</span><span class="p">,</span> -</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> <span class="s2">"array"</span><span class="p">,</span> -</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a> <span class="s2">"as"</span><span class="p">,</span> -</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a> <span class="s2">"asc"</span><span class="p">,</span> -</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="s2">"assert_rows_modified"</span><span class="p">,</span> -</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="s2">"at"</span><span class="p">,</span> -</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="s2">"between"</span><span class="p">,</span> -</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</span></a> <span class="s2">"by"</span><span class="p">,</span> -</span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> <span class="s2">"case"</span><span class="p">,</span> -</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="s2">"cast"</span><span class="p">,</span> -</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> <span class="s2">"collate"</span><span class="p">,</span> -</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> <span class="s2">"contains"</span><span class="p">,</span> -</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</span></a> <span class="s2">"create"</span><span class="p">,</span> -</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> <span class="s2">"cross"</span><span class="p">,</span> -</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> <span class="s2">"cube"</span><span class="p">,</span> -</span><span id="L-1022"><a href="#L-1022"><span class="linenos">1022</span></a> <span class="s2">"current"</span><span class="p">,</span> -</span><span id="L-1023"><a href="#L-1023"><span class="linenos">1023</span></a> <span class="s2">"default"</span><span class="p">,</span> -</span><span id="L-1024"><a href="#L-1024"><span class="linenos">1024</span></a> <span class="s2">"define"</span><span class="p">,</span> -</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> <span class="s2">"desc"</span><span class="p">,</span> -</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</span></a> <span class="s2">"distinct"</span><span class="p">,</span> -</span><span id="L-1027"><a href="#L-1027"><span class="linenos">1027</span></a> <span class="s2">"else"</span><span class="p">,</span> -</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</span></a> <span class="s2">"end"</span><span class="p">,</span> -</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</span></a> <span class="s2">"enum"</span><span class="p">,</span> -</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> <span class="s2">"escape"</span><span class="p">,</span> -</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> <span class="s2">"except"</span><span class="p">,</span> -</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> <span class="s2">"exclude"</span><span class="p">,</span> -</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> <span class="s2">"exists"</span><span class="p">,</span> -</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</span></a> <span class="s2">"extract"</span><span class="p">,</span> -</span><span id="L-1035"><a href="#L-1035"><span class="linenos">1035</span></a> <span class="s2">"false"</span><span class="p">,</span> -</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</span></a> <span class="s2">"fetch"</span><span class="p">,</span> -</span><span id="L-1037"><a href="#L-1037"><span class="linenos">1037</span></a> <span class="s2">"following"</span><span class="p">,</span> -</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</span></a> <span class="s2">"for"</span><span class="p">,</span> -</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> <span class="s2">"full"</span><span class="p">,</span> -</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</span></a> <span class="s2">"group"</span><span class="p">,</span> -</span><span id="L-1042"><a href="#L-1042"><span class="linenos">1042</span></a> <span class="s2">"grouping"</span><span class="p">,</span> -</span><span id="L-1043"><a href="#L-1043"><span class="linenos">1043</span></a> <span class="s2">"groups"</span><span class="p">,</span> -</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</span></a> <span class="s2">"hash"</span><span class="p">,</span> -</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> <span class="s2">"having"</span><span class="p">,</span> -</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</span></a> <span class="s2">"if"</span><span class="p">,</span> -</span><span id="L-1047"><a href="#L-1047"><span class="linenos">1047</span></a> <span class="s2">"ignore"</span><span class="p">,</span> -</span><span id="L-1048"><a href="#L-1048"><span class="linenos">1048</span></a> <span class="s2">"in"</span><span class="p">,</span> -</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</span></a> <span class="s2">"inner"</span><span class="p">,</span> -</span><span id="L-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="s2">"intersect"</span><span class="p">,</span> -</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</span></a> <span class="s2">"interval"</span><span class="p">,</span> -</span><span id="L-1052"><a href="#L-1052"><span class="linenos">1052</span></a> <span class="s2">"into"</span><span class="p">,</span> -</span><span id="L-1053"><a href="#L-1053"><span class="linenos">1053</span></a> <span class="s2">"is"</span><span class="p">,</span> -</span><span id="L-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="s2">"join"</span><span class="p">,</span> -</span><span id="L-1055"><a href="#L-1055"><span class="linenos">1055</span></a> <span class="s2">"lateral"</span><span class="p">,</span> -</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> <span class="s2">"left"</span><span class="p">,</span> -</span><span id="L-1057"><a href="#L-1057"><span class="linenos">1057</span></a> <span class="s2">"like"</span><span class="p">,</span> -</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</span></a> <span class="s2">"limit"</span><span class="p">,</span> -</span><span id="L-1059"><a href="#L-1059"><span class="linenos">1059</span></a> <span class="s2">"lookup"</span><span class="p">,</span> -</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</span></a> <span class="s2">"merge"</span><span class="p">,</span> -</span><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> <span class="s2">"natural"</span><span class="p">,</span> -</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="s2">"new"</span><span class="p">,</span> -</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> <span class="s2">"no"</span><span class="p">,</span> -</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> <span class="s2">"not"</span><span class="p">,</span> -</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> <span class="s2">"null"</span><span class="p">,</span> -</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="s2">"nulls"</span><span class="p">,</span> -</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="s2">"of"</span><span class="p">,</span> -</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</span></a> <span class="s2">"on"</span><span class="p">,</span> -</span><span id="L-1069"><a href="#L-1069"><span class="linenos">1069</span></a> <span class="s2">"or"</span><span class="p">,</span> -</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> <span class="s2">"order"</span><span class="p">,</span> -</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> <span class="s2">"outer"</span><span class="p">,</span> -</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="s2">"over"</span><span class="p">,</span> -</span><span id="L-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="s2">"partition"</span><span class="p">,</span> -</span><span id="L-1074"><a href="#L-1074"><span class="linenos">1074</span></a> <span class="s2">"preceding"</span><span class="p">,</span> -</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> <span class="s2">"proto"</span><span class="p">,</span> -</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</span></a> <span class="s2">"qualify"</span><span class="p">,</span> -</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</span></a> <span class="s2">"range"</span><span class="p">,</span> -</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</span></a> <span class="s2">"recursive"</span><span class="p">,</span> -</span><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="s2">"respect"</span><span class="p">,</span> -</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> <span class="s2">"right"</span><span class="p">,</span> -</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> <span class="s2">"rollup"</span><span class="p">,</span> -</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> <span class="s2">"rows"</span><span class="p">,</span> -</span><span id="L-1083"><a href="#L-1083"><span class="linenos">1083</span></a> <span class="s2">"select"</span><span class="p">,</span> -</span><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> <span class="s2">"set"</span><span class="p">,</span> -</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> <span class="s2">"some"</span><span class="p">,</span> -</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</span></a> <span class="s2">"struct"</span><span class="p">,</span> -</span><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> <span class="s2">"tablesample"</span><span class="p">,</span> -</span><span id="L-1088"><a href="#L-1088"><span class="linenos">1088</span></a> <span class="s2">"then"</span><span class="p">,</span> -</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> <span class="s2">"treat"</span><span class="p">,</span> -</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> <span class="s2">"true"</span><span class="p">,</span> -</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> <span class="s2">"unbounded"</span><span class="p">,</span> -</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> <span class="s2">"union"</span><span class="p">,</span> -</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> <span class="s2">"unnest"</span><span class="p">,</span> -</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> <span class="s2">"using"</span><span class="p">,</span> -</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> <span class="s2">"when"</span><span class="p">,</span> -</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> <span class="s2">"window"</span><span class="p">,</span> -</span><span id="L-1099"><a href="#L-1099"><span class="linenos">1099</span></a> <span class="s2">"with"</span><span class="p">,</span> -</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> <span class="s2">"within"</span><span class="p">,</span> -</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="p">}</span> -</span><span id="L-1102"><a href="#L-1102"><span class="linenos">1102</span></a> -</span><span id="L-1103"><a href="#L-1103"><span class="linenos">1103</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-1107"><a href="#L-1107"><span class="linenos">1107</span></a> <span class="s2">"MOD"</span><span class="p">,</span> -</span><span id="L-1108"><a href="#L-1108"><span class="linenos">1108</span></a> <span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <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">Paren</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> -</span><span id="L-1109"><a href="#L-1109"><span class="linenos">1109</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</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="k">else</span> <span class="n">expr</span><span class="p">,</span> -</span><span id="L-1110"><a href="#L-1110"><span class="linenos">1110</span></a> <span class="p">)</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">def</span> <span class="nf">column_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1113"><a href="#L-1113"><span class="linenos">1113</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_column"</span><span class="p">):</span> -</span><span id="L-1114"><a href="#L-1114"><span class="linenos">1114</span></a> <span class="c1"># If a column reference is of the form `dataset.table`.name, we need</span> -</span><span id="L-1115"><a href="#L-1115"><span class="linenos">1115</span></a> <span class="c1"># to preserve the quoted table path, otherwise the reference breaks</span> -</span><span id="L-1116"><a href="#L-1116"><span class="linenos">1116</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> -</span><span id="L-1117"><a href="#L-1117"><span class="linenos">1117</span></a> <span class="n">table_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</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-1118"><a href="#L-1118"><span class="linenos">1118</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_path</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> -</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">column_parts</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">table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> <span class="c1"># Depending on the context, `x.y` may not resolve to the same data source as `x`.`y`, so</span> -</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="c1"># we need to make sure the correct quoting is used in each case.</span> -</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> <span class="c1">#</span> -</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> <span class="c1"># For example, if there is a CTE x that clashes with a schema name, then the former will</span> -</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> <span class="c1"># return the table y in that schema, whereas the latter will return the CTE's y column:</span> -</span><span id="L-1128"><a href="#L-1128"><span class="linenos">1128</span></a> <span class="c1">#</span> -</span><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x.y` -> cross join</span> -</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x`.`y` -> implicit unnest</span> -</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_table"</span><span class="p">):</span> -</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">)</span> -</span><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</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-1134"><a href="#L-1134"><span class="linenos">1134</span></a> -</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">table_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</span></a> -</span><span id="L-1137"><a href="#L-1137"><span class="linenos">1137</span></a> <span class="k">def</span> <span class="nf">timetostr_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-1139"><a href="#L-1139"><span class="linenos">1139</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">TsOrDsToDatetime</span><span class="p">):</span> -</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATETIME"</span> -</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</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">TsOrDsToTimestamp</span><span class="p">):</span> -</span><span id="L-1142"><a href="#L-1142"><span class="linenos">1142</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_TIMESTAMP"</span> -</span><span id="L-1143"><a href="#L-1143"><span class="linenos">1143</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1144"><a href="#L-1144"><span class="linenos">1144</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATE"</span> -</span><span id="L-1145"><a href="#L-1145"><span class="linenos">1145</span></a> -</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</span></a> <span class="n">time_expr</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1147"><a href="#L-1147"><span class="linenos">1147</span></a> <span class="n">this</span> -</span><span id="L-1148"><a href="#L-1148"><span class="linenos">1148</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="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">))</span> -</span><span id="L-1149"><a href="#L-1149"><span class="linenos">1149</span></a> <span class="k">else</span> <span class="n">expression</span> -</span><span id="L-1150"><a href="#L-1150"><span class="linenos">1150</span></a> <span class="p">)</span> -</span><span id="L-1151"><a href="#L-1151"><span class="linenos">1151</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">time_expr</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-1152"><a href="#L-1152"><span class="linenos">1152</span></a> -</span><span id="L-1153"><a href="#L-1153"><span class="linenos">1153</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1154"><a href="#L-1154"><span class="linenos">1154</span></a> <span class="c1"># Operands of = cannot be NULL in BigQuery</span> -</span><span id="L-1155"><a href="#L-1155"><span class="linenos">1155</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">right</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">):</span> -</span><span id="L-1156"><a href="#L-1156"><span class="linenos">1156</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="L-1157"><a href="#L-1157"><span class="linenos">1157</span></a> <span class="k">return</span> <span class="s2">"NULL"</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">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> -</span><span id="L-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="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1162"><a href="#L-1162"><span class="linenos">1162</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</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="c1"># BigQuery allows CAST(.. AS {STRING|TIMESTAMP} [FORMAT <fmt> [AT TIME ZONE <tz>]]).</span> -</span><span id="L-1165"><a href="#L-1165"><span class="linenos">1165</span></a> <span class="c1"># Only the TIMESTAMP one should use the below conversion, when AT TIME ZONE is included.</span> -</span><span id="L-1166"><a href="#L-1166"><span class="linenos">1166</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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> -</span><span id="L-1167"><a href="#L-1167"><span class="linenos">1167</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-1168"><a href="#L-1168"><span class="linenos">1168</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">))</span> -</span><span id="L-1169"><a href="#L-1169"><span class="linenos">1169</span></a> <span class="p">)</span> -</span><span id="L-1170"><a href="#L-1170"><span class="linenos">1170</span></a> -</span><span id="L-1171"><a href="#L-1171"><span class="linenos">1171</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">attimezone_sql</span><span class="p">(</span><span class="n">expression</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="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1174"><a href="#L-1174"><span class="linenos">1174</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"SAFE_"</span><span class="p">)</span> -</span><span id="L-1175"><a href="#L-1175"><span class="linenos">1175</span></a> -</span><span id="L-1176"><a href="#L-1176"><span class="linenos">1176</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1177"><a href="#L-1177"><span class="linenos">1177</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-1178"><a href="#L-1178"><span class="linenos">1178</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-811"><a href="#L-811"><span class="linenos"> 811</span></a> <span class="bp">self</span><span 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-812"><a href="#L-812"><span class="linenos"> 812</span></a> +</span><span id="L-813"><a href="#L-813"><span class="linenos"> 813</span></a> <span class="k">return</span> <span class="n">expr</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="k">def</span> <span class="nf">_parse_features_at_time</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">:</span> +</span><span id="L-816"><a href="#L-816"><span class="linenos"> 816</span></a> <span class="n">expr</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-817"><a href="#L-817"><span class="linenos"> 817</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">,</span> +</span><span id="L-818"><a href="#L-818"><span class="linenos"> 818</span></a> <span class="n">this</span><span class="o">=</span><span class="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">TABLE</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-819"><a href="#L-819"><span class="linenos"> 819</span></a> <span class="ow">or</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-820"><a href="#L-820"><span class="linenos"> 820</span></a> <span class="p">)</span> +</span><span id="L-821"><a href="#L-821"><span class="linenos"> 821</span></a> +</span><span id="L-822"><a href="#L-822"><span class="linenos"> 822</span></a> <span class="k">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">COMMA</span><span class="p">):</span> +</span><span id="L-823"><a href="#L-823"><span class="linenos"> 823</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> +</span><span id="L-824"><a href="#L-824"><span class="linenos"> 824</span></a> +</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> <span class="c1"># Get the LHS of the Kwarg and set the arg to that value, e.g</span> +</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="c1"># "num_rows => 1" sets the expr's `num_rows` arg</span> +</span><span id="L-827"><a href="#L-827"><span class="linenos"> 827</span></a> <span class="k">if</span> <span class="n">arg</span><span class="p">:</span> +</span><span id="L-828"><a href="#L-828"><span class="linenos"> 828</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-829"><a href="#L-829"><span class="linenos"> 829</span></a> +</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> <span class="k">return</span> <span class="n">expr</span> +</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> +</span><span id="L-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="n">UNNEST_WITH_ORDINALITY</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="n">COLLATE_IS_FUNC</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-842"><a href="#L-842"><span class="linenos"> 842</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> <span class="n">SUPPORTS_TABLE_ALIAS_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="n">UNPIVOT_ALIASES_ARE_IDENTIFIERS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> <span class="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-848"><a href="#L-848"><span class="linenos"> 848</span></a> <span class="n">JSON_PATH_SINGLE_QUOTE_ESCAPE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-849"><a href="#L-849"><span class="linenos"> 849</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-851"><a href="#L-851"><span class="linenos"> 851</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> +</span><span id="L-852"><a href="#L-852"><span class="linenos"> 852</span></a> <span class="n">HEX_FUNC</span> <span class="o">=</span> <span class="s2">"TO_HEX"</span> +</span><span id="L-853"><a href="#L-853"><span class="linenos"> 853</span></a> <span class="n">WITH_PROPERTIES_PREFIX</span> <span class="o">=</span> <span class="s2">"OPTIONS"</span> +</span><span id="L-854"><a href="#L-854"><span class="linenos"> 854</span></a> <span class="n">SUPPORTS_EXPLODING_PROJECTIONS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-855"><a href="#L-855"><span class="linenos"> 855</span></a> <span class="n">EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</span></a> <span class="n">SUPPORTS_UNIX_SECONDS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-857"><a href="#L-857"><span class="linenos"> 857</span></a> +</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="L-860"><a href="#L-860"><span class="linenos"> 860</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> +</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> +</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> +</span><span id="L-863"><a href="#L-863"><span class="linenos"> 863</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> +</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">_array_contains_sql</span><span class="p">,</span> +</span><span id="L-865"><a href="#L-865"><span class="linenos"> 865</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">filter_array_using_unnest</span><span class="p">,</span> +</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_precision_parameterized_types</span><span class="p">]),</span> +</span><span id="L-867"><a href="#L-867"><span class="linenos"> 867</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> +</span><span id="L-868"><a href="#L-868"><span class="linenos"> 868</span></a> <span class="sa">f</span><span class="s2">"DEFAULT COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-869"><a href="#L-869"><span class="linenos"> 869</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> +</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-871"><a href="#L-871"><span class="linenos"> 871</span></a> <span class="p">),</span> +</span><span id="L-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"COMMIT TRANSACTION"</span><span class="p">,</span> +</span><span id="L-873"><a href="#L-873"><span class="linenos"> 873</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COUNTIF"</span><span class="p">),</span> +</span><span id="L-874"><a href="#L-874"><span class="linenos"> 874</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> +</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_pushdown_cte_column_names</span><span class="p">]),</span> +</span><span id="L-876"><a href="#L-876"><span class="linenos"> 876</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">unit_to_var</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a> <span class="p">),</span> +</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">),</span> +</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> +</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)</span> +</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</span></a> <span class="p">),</span> +</span><span id="L-888"><a href="#L-888"><span class="linenos"> 888</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromTimeZone</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> <span class="s2">"DATETIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)),</span> <span class="s2">"'UTC'"</span> +</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> <span class="p">),</span> +</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GENERATE_ARRAY"</span><span class="p">),</span> +</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> +</span><span id="L-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> +</span><span id="L-894"><a href="#L-894"><span class="linenos"> 894</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(</span><span class="n">false_value</span><span class="o">=</span><span class="s2">"NULL"</span><span class="p">),</span> +</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> +</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Int64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"INT64"</span><span class="p">),</span> +</span><span id="L-898"><a href="#L-898"><span class="linenos"> 898</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> +</span><span id="L-899"><a href="#L-899"><span class="linenos"> 899</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractArray</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> +</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> +</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_JSON_STRING"</span><span class="p">),</span> +</span><span id="L-902"><a href="#L-902"><span class="linenos"> 902</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">_levenshtein_sql</span><span class="p">,</span> +</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> +</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">),</span> +</span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="L-907"><a href="#L-907"><span class="linenos"> 907</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-909"><a href="#L-909"><span class="linenos"> 909</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> +</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">),</span> +</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"occurrence"</span><span class="p">),</span> +</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</span></a> <span class="p">),</span> +</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtractAll</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> <span class="s2">"REGEXP_EXTRACT_ALL"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> <span class="p">),</span> +</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="n">regexp_replace_sql</span><span class="p">,</span> +</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_CONTAINS"</span><span class="p">),</span> +</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> +</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"ROLLBACK TRANSACTION"</span><span class="p">,</span> +</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> <span class="p">[</span> +</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(),</span> +</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> +</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="n">_alias_ordered_group</span><span class="p">,</span> +</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">,</span> +</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</span></a> <span class="p">]</span> +</span><span id="L-930"><a href="#L-930"><span class="linenos"> 930</span></a> <span class="p">),</span> +</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SHA1"</span><span class="p">),</span> +</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA2</span><span class="p">:</span> <span class="n">sha256_sql</span><span class="p">,</span> +</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> +</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> <span class="s2">"DETERMINISTIC"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span> +</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> <span class="p">),</span> +</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">String</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING"</span><span class="p">),</span> +</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> +</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> +</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> +</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> +</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> +</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP_DIFF"</span><span class="p">),</span> +</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">,</span> +</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">_ts_or_ds_diff_sql</span><span class="p">,</span> +</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> +</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> +</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">),</span> +</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> +</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_DATE"</span><span class="p">),</span> +</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> +</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uuid</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"GENERATE_UUID()"</span><span class="p">,</span> +</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> +</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> +</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> <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">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> +</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> +</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> +</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="p">}</span> +</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> +</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> +</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> +</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">:</span> <span class="s2">"NUMERIC"</span><span class="p">,</span> +</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> +</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UUID</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> +</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> <span class="p">}</span> +</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> +</span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="p">}</span> +</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> +</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> <span class="c1"># WINDOW comes after QUALIFY</span> +</span><span id="L-1001"><a href="#L-1001"><span class="linenos">1001</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#window_clause</span> +</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a> <span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> <span class="s2">"qualify"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"qualify"</span><span class="p">],</span> +</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> <span class="s2">"windows"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"windows"</span><span class="p">],</span> +</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a> <span class="p">}</span> +</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a> +</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> <span class="c1"># from: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords</span> +</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</span></a> <span class="s2">"asc"</span><span class="p">,</span> +</span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> <span class="s2">"assert_rows_modified"</span><span class="p">,</span> +</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="s2">"at"</span><span class="p">,</span> +</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> <span class="s2">"between"</span><span class="p">,</span> +</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> <span class="s2">"by"</span><span class="p">,</span> +</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="L-1022"><a href="#L-1022"><span class="linenos">1022</span></a> <span class="s2">"contains"</span><span class="p">,</span> +</span><span id="L-1023"><a href="#L-1023"><span class="linenos">1023</span></a> <span class="s2">"create"</span><span class="p">,</span> +</span><span id="L-1024"><a href="#L-1024"><span class="linenos">1024</span></a> <span class="s2">"cross"</span><span class="p">,</span> +</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> <span class="s2">"cube"</span><span class="p">,</span> +</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</span></a> <span class="s2">"current"</span><span class="p">,</span> +</span><span id="L-1027"><a href="#L-1027"><span class="linenos">1027</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</span></a> <span class="s2">"define"</span><span class="p">,</span> +</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</span></a> <span class="s2">"desc"</span><span class="p">,</span> +</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> <span class="s2">"end"</span><span class="p">,</span> +</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> <span class="s2">"enum"</span><span class="p">,</span> +</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</span></a> <span class="s2">"escape"</span><span class="p">,</span> +</span><span id="L-1035"><a href="#L-1035"><span class="linenos">1035</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</span></a> <span class="s2">"exclude"</span><span class="p">,</span> +</span><span id="L-1037"><a href="#L-1037"><span class="linenos">1037</span></a> <span class="s2">"exists"</span><span class="p">,</span> +</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</span></a> <span class="s2">"extract"</span><span class="p">,</span> +</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> <span class="s2">"false"</span><span class="p">,</span> +</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> <span class="s2">"fetch"</span><span class="p">,</span> +</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</span></a> <span class="s2">"following"</span><span class="p">,</span> +</span><span id="L-1042"><a href="#L-1042"><span class="linenos">1042</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="L-1043"><a href="#L-1043"><span class="linenos">1043</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</span></a> <span class="s2">"full"</span><span class="p">,</span> +</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> <span class="s2">"group"</span><span class="p">,</span> +</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</span></a> <span class="s2">"grouping"</span><span class="p">,</span> +</span><span id="L-1047"><a href="#L-1047"><span class="linenos">1047</span></a> <span class="s2">"groups"</span><span class="p">,</span> +</span><span id="L-1048"><a href="#L-1048"><span class="linenos">1048</span></a> <span class="s2">"hash"</span><span class="p">,</span> +</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="L-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="s2">"if"</span><span class="p">,</span> +</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</span></a> <span class="s2">"ignore"</span><span class="p">,</span> +</span><span id="L-1052"><a href="#L-1052"><span class="linenos">1052</span></a> <span class="s2">"in"</span><span class="p">,</span> +</span><span id="L-1053"><a href="#L-1053"><span class="linenos">1053</span></a> <span class="s2">"inner"</span><span class="p">,</span> +</span><span id="L-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="L-1055"><a href="#L-1055"><span class="linenos">1055</span></a> <span class="s2">"interval"</span><span class="p">,</span> +</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="L-1057"><a href="#L-1057"><span class="linenos">1057</span></a> <span class="s2">"is"</span><span class="p">,</span> +</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</span></a> <span class="s2">"join"</span><span class="p">,</span> +</span><span id="L-1059"><a href="#L-1059"><span class="linenos">1059</span></a> <span class="s2">"lateral"</span><span class="p">,</span> +</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</span></a> <span class="s2">"left"</span><span class="p">,</span> +</span><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> <span class="s2">"like"</span><span class="p">,</span> +</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> <span class="s2">"lookup"</span><span class="p">,</span> +</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> <span class="s2">"merge"</span><span class="p">,</span> +</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> <span class="s2">"natural"</span><span class="p">,</span> +</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="s2">"new"</span><span class="p">,</span> +</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="s2">"no"</span><span class="p">,</span> +</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="L-1069"><a href="#L-1069"><span class="linenos">1069</span></a> <span class="s2">"null"</span><span class="p">,</span> +</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> <span class="s2">"nulls"</span><span class="p">,</span> +</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> <span class="s2">"of"</span><span class="p">,</span> +</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="L-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="L-1074"><a href="#L-1074"><span class="linenos">1074</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> <span class="s2">"outer"</span><span class="p">,</span> +</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</span></a> <span class="s2">"over"</span><span class="p">,</span> +</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</span></a> <span class="s2">"partition"</span><span class="p">,</span> +</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</span></a> <span class="s2">"preceding"</span><span class="p">,</span> +</span><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="s2">"proto"</span><span class="p">,</span> +</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> <span class="s2">"qualify"</span><span class="p">,</span> +</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> <span class="s2">"range"</span><span class="p">,</span> +</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> <span class="s2">"recursive"</span><span class="p">,</span> +</span><span id="L-1083"><a href="#L-1083"><span class="linenos">1083</span></a> <span class="s2">"respect"</span><span class="p">,</span> +</span><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> <span class="s2">"right"</span><span class="p">,</span> +</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> <span class="s2">"rollup"</span><span class="p">,</span> +</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</span></a> <span class="s2">"rows"</span><span class="p">,</span> +</span><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="L-1088"><a href="#L-1088"><span class="linenos">1088</span></a> <span class="s2">"set"</span><span class="p">,</span> +</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> <span class="s2">"struct"</span><span class="p">,</span> +</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> <span class="s2">"tablesample"</span><span class="p">,</span> +</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> <span class="s2">"treat"</span><span class="p">,</span> +</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> <span class="s2">"true"</span><span class="p">,</span> +</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> <span class="s2">"unbounded"</span><span class="p">,</span> +</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> <span class="s2">"unnest"</span><span class="p">,</span> +</span><span id="L-1099"><a href="#L-1099"><span class="linenos">1099</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="L-1102"><a href="#L-1102"><span class="linenos">1102</span></a> <span class="s2">"window"</span><span class="p">,</span> +</span><span id="L-1103"><a href="#L-1103"><span class="linenos">1103</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="s2">"within"</span><span class="p">,</span> +</span><span id="L-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="p">}</span> +</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> +</span><span id="L-1107"><a href="#L-1107"><span class="linenos">1107</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1108"><a href="#L-1108"><span class="linenos">1108</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-1109"><a href="#L-1109"><span class="linenos">1109</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-1110"><a href="#L-1110"><span class="linenos">1110</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-1111"><a href="#L-1111"><span class="linenos">1111</span></a> <span class="s2">"MOD"</span><span class="p">,</span> +</span><span id="L-1112"><a href="#L-1112"><span class="linenos">1112</span></a> <span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <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">Paren</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> +</span><span id="L-1113"><a href="#L-1113"><span class="linenos">1113</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</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="k">else</span> <span class="n">expr</span><span class="p">,</span> +</span><span id="L-1114"><a href="#L-1114"><span class="linenos">1114</span></a> <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">def</span> <span class="nf">column_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1117"><a href="#L-1117"><span class="linenos">1117</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_column"</span><span class="p">):</span> +</span><span id="L-1118"><a href="#L-1118"><span class="linenos">1118</span></a> <span class="c1"># If a column reference is of the form `dataset.table`.name, we need</span> +</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> <span class="c1"># to preserve the quoted table path, otherwise the reference breaks</span> +</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> +</span><span id="L-1121"><a href="#L-1121"><span class="linenos">1121</span></a> <span class="n">table_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</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-1122"><a href="#L-1122"><span class="linenos">1122</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_path</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> +</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">column_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> +</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> <span class="k">def</span> <span class="nf">table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> <span class="c1"># Depending on the context, `x.y` may not resolve to the same data source as `x`.`y`, so</span> +</span><span id="L-1128"><a href="#L-1128"><span class="linenos">1128</span></a> <span class="c1"># we need to make sure the correct quoting is used in each case.</span> +</span><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</span></a> <span class="c1">#</span> +</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> <span class="c1"># For example, if there is a CTE x that clashes with a schema name, then the former will</span> +</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> <span class="c1"># return the table y in that schema, whereas the latter will return the CTE's y column:</span> +</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</span></a> <span class="c1">#</span> +</span><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x.y` -> cross join</span> +</span><span id="L-1134"><a href="#L-1134"><span class="linenos">1134</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x`.`y` -> implicit unnest</span> +</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_table"</span><span class="p">):</span> +</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">)</span> +</span><span id="L-1137"><a href="#L-1137"><span class="linenos">1137</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> +</span><span id="L-1139"><a href="#L-1139"><span class="linenos">1139</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">table_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</span></a> +</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</span></a> <span class="k">def</span> <span class="nf">timetostr_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1142"><a href="#L-1142"><span class="linenos">1142</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-1143"><a href="#L-1143"><span class="linenos">1143</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">TsOrDsToDatetime</span><span class="p">):</span> +</span><span id="L-1144"><a href="#L-1144"><span class="linenos">1144</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATETIME"</span> +</span><span id="L-1145"><a href="#L-1145"><span class="linenos">1145</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">TsOrDsToTimestamp</span><span class="p">):</span> +</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_TIMESTAMP"</span> +</span><span id="L-1147"><a href="#L-1147"><span class="linenos">1147</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1148"><a href="#L-1148"><span class="linenos">1148</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATE"</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="n">time_expr</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1151"><a href="#L-1151"><span class="linenos">1151</span></a> <span class="n">this</span> +</span><span id="L-1152"><a href="#L-1152"><span class="linenos">1152</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="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">))</span> +</span><span id="L-1153"><a href="#L-1153"><span class="linenos">1153</span></a> <span class="k">else</span> <span class="n">expression</span> +</span><span id="L-1154"><a href="#L-1154"><span class="linenos">1154</span></a> <span class="p">)</span> +</span><span id="L-1155"><a href="#L-1155"><span class="linenos">1155</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">time_expr</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-1156"><a href="#L-1156"><span class="linenos">1156</span></a> +</span><span id="L-1157"><a href="#L-1157"><span class="linenos">1157</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1158"><a href="#L-1158"><span class="linenos">1158</span></a> <span class="c1"># Operands of = cannot be NULL in BigQuery</span> +</span><span id="L-1159"><a href="#L-1159"><span class="linenos">1159</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">right</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">):</span> +</span><span id="L-1160"><a href="#L-1160"><span class="linenos">1160</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="L-1161"><a href="#L-1161"><span class="linenos">1161</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> +</span><span id="L-1162"><a href="#L-1162"><span class="linenos">1162</span></a> +</span><span id="L-1163"><a href="#L-1163"><span class="linenos">1163</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> +</span><span id="L-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">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1166"><a href="#L-1166"><span class="linenos">1166</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> +</span><span id="L-1167"><a href="#L-1167"><span class="linenos">1167</span></a> +</span><span id="L-1168"><a href="#L-1168"><span class="linenos">1168</span></a> <span class="c1"># BigQuery allows CAST(.. AS {STRING|TIMESTAMP} [FORMAT <fmt> [AT TIME ZONE <tz>]]).</span> +</span><span id="L-1169"><a href="#L-1169"><span class="linenos">1169</span></a> <span class="c1"># Only the TIMESTAMP one should use the below conversion, when AT TIME ZONE is included.</span> +</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="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">Cast</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</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">func</span><span class="p">(</span> +</span><span id="L-1172"><a href="#L-1172"><span class="linenos">1172</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">))</span> +</span><span id="L-1173"><a href="#L-1173"><span class="linenos">1173</span></a> <span class="p">)</span> +</span><span id="L-1174"><a href="#L-1174"><span class="linenos">1174</span></a> +</span><span id="L-1175"><a href="#L-1175"><span class="linenos">1175</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">attimezone_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1176"><a href="#L-1176"><span class="linenos">1176</span></a> +</span><span id="L-1177"><a href="#L-1177"><span class="linenos">1177</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1178"><a href="#L-1178"><span class="linenos">1178</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"SAFE_"</span><span class="p">)</span> </span><span id="L-1179"><a href="#L-1179"><span class="linenos">1179</span></a> -</span><span id="L-1180"><a href="#L-1180"><span class="linenos">1180</span></a> <span class="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="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">):</span> -</span><span id="L-1181"><a href="#L-1181"><span class="linenos">1181</span></a> <span class="n">arg</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-1182"><a href="#L-1182"><span class="linenos">1182</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1183"><a href="#L-1183"><span class="linenos">1183</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> -</span><span id="L-1184"><a href="#L-1184"><span class="linenos">1184</span></a> -</span><span id="L-1185"><a href="#L-1185"><span class="linenos">1185</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> -</span><span id="L-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">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">and</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</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">TEXT_TYPES</span><span class="p">:</span> -</span><span id="L-1188"><a href="#L-1188"><span class="linenos">1188</span></a> <span class="c1"># BQ doesn't support bracket syntax with string values for structs</span> -</span><span id="L-1189"><a href="#L-1189"><span class="linenos">1189</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1180"><a href="#L-1180"><span class="linenos">1180</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1181"><a href="#L-1181"><span class="linenos">1181</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-1182"><a href="#L-1182"><span class="linenos">1182</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-1183"><a href="#L-1183"><span class="linenos">1183</span></a> +</span><span id="L-1184"><a href="#L-1184"><span class="linenos">1184</span></a> <span class="k">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="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">):</span> +</span><span id="L-1185"><a href="#L-1185"><span class="linenos">1185</span></a> <span class="n">arg</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-1186"><a href="#L-1186"><span class="linenos">1186</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1187"><a href="#L-1187"><span class="linenos">1187</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="L-1188"><a href="#L-1188"><span class="linenos">1188</span></a> +</span><span id="L-1189"><a href="#L-1189"><span class="linenos">1189</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> </span><span id="L-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="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1192"><a href="#L-1192"><span class="linenos">1192</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> -</span><span id="L-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="k">if</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="L-1195"><a href="#L-1195"><span class="linenos">1195</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OFFSET(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1196"><a href="#L-1196"><span class="linenos">1196</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-1197"><a href="#L-1197"><span class="linenos">1197</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ORDINAL(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1198"><a href="#L-1198"><span class="linenos">1198</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1199"><a href="#L-1199"><span class="linenos">1199</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported array offset: </span><span class="si">{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1200"><a href="#L-1200"><span class="linenos">1200</span></a> -</span><span id="L-1201"><a href="#L-1201"><span class="linenos">1201</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">):</span> -</span><span id="L-1202"><a href="#L-1202"><span class="linenos">1202</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"SAFE_</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1203"><a href="#L-1203"><span class="linenos">1203</span></a> -</span><span id="L-1204"><a href="#L-1204"><span class="linenos">1204</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> -</span><span id="L-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="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1207"><a href="#L-1207"><span class="linenos">1207</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-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="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1210"><a href="#L-1210"><span class="linenos">1210</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> -</span><span id="L-1211"><a href="#L-1211"><span class="linenos">1211</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"SYSTEM_TIME"</span><span class="p">)</span> -</span><span id="L-1212"><a href="#L-1212"><span class="linenos">1212</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">version_sql</span><span class="p">(</span><span class="n">expression</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="k">def</span> <span class="nf">contains_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Contains</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1215"><a href="#L-1215"><span class="linenos">1215</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-1216"><a href="#L-1216"><span class="linenos">1216</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-1191"><a href="#L-1191"><span class="linenos">1191</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">and</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</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">TEXT_TYPES</span><span class="p">:</span> +</span><span id="L-1192"><a href="#L-1192"><span class="linenos">1192</span></a> <span class="c1"># BQ doesn't support bracket syntax with string values for structs</span> +</span><span id="L-1193"><a href="#L-1193"><span class="linenos">1193</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1194"><a href="#L-1194"><span class="linenos">1194</span></a> +</span><span id="L-1195"><a href="#L-1195"><span class="linenos">1195</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1196"><a href="#L-1196"><span class="linenos">1196</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> +</span><span id="L-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">offset</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="L-1199"><a href="#L-1199"><span class="linenos">1199</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OFFSET(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1200"><a href="#L-1200"><span class="linenos">1200</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-1201"><a href="#L-1201"><span class="linenos">1201</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ORDINAL(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1202"><a href="#L-1202"><span class="linenos">1202</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1203"><a href="#L-1203"><span class="linenos">1203</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported array offset: </span><span class="si">{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</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="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">):</span> +</span><span id="L-1206"><a href="#L-1206"><span class="linenos">1206</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"SAFE_</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1207"><a href="#L-1207"><span class="linenos">1207</span></a> +</span><span id="L-1208"><a href="#L-1208"><span class="linenos">1208</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="L-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="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1211"><a href="#L-1211"><span class="linenos">1211</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1212"><a href="#L-1212"><span class="linenos">1212</span></a> +</span><span id="L-1213"><a href="#L-1213"><span class="linenos">1213</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1214"><a href="#L-1214"><span class="linenos">1214</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> +</span><span id="L-1215"><a href="#L-1215"><span class="linenos">1215</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"SYSTEM_TIME"</span><span class="p">)</span> +</span><span id="L-1216"><a href="#L-1216"><span class="linenos">1216</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">version_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-1217"><a href="#L-1217"><span class="linenos">1217</span></a> -</span><span id="L-1218"><a href="#L-1218"><span class="linenos">1218</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">Lower</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">):</span> -</span><span id="L-1219"><a href="#L-1219"><span class="linenos">1219</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-1220"><a href="#L-1220"><span class="linenos">1220</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-1218"><a href="#L-1218"><span class="linenos">1218</span></a> <span class="k">def</span> <span class="nf">contains_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Contains</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1219"><a href="#L-1219"><span class="linenos">1219</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-1220"><a href="#L-1220"><span class="linenos">1220</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</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">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONTAINS_SUBSTR"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> +</span><span id="L-1222"><a href="#L-1222"><span class="linenos">1222</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">Lower</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">):</span> +</span><span id="L-1223"><a href="#L-1223"><span class="linenos">1223</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-1224"><a href="#L-1224"><span class="linenos">1224</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-1225"><a href="#L-1225"><span class="linenos">1225</span></a> +</span><span id="L-1226"><a href="#L-1226"><span class="linenos">1226</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONTAINS_SUBSTR"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> </span></pre></div> @@ -1936,637 +1943,641 @@ </span><span id="BigQuery-590"><a href="#BigQuery-590"><span class="linenos"> 590</span></a> </span><span id="BigQuery-591"><a href="#BigQuery-591"><span class="linenos"> 591</span></a> <span class="n">NULL_TOKENS</span> <span class="o">=</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">UNKNOWN</span><span class="p">}</span> </span><span id="BigQuery-592"><a href="#BigQuery-592"><span class="linenos"> 592</span></a> -</span><span id="BigQuery-593"><a href="#BigQuery-593"><span class="linenos"> 593</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-594"><a href="#BigQuery-594"><span class="linenos"> 594</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> -</span><span id="BigQuery-595"><a href="#BigQuery-595"><span class="linenos"> 595</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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="BigQuery-596"><a href="#BigQuery-596"><span class="linenos"> 596</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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="BigQuery-597"><a href="#BigQuery-597"><span class="linenos"> 597</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">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">_parse_for_in</span><span class="p">(),</span> -</span><span id="BigQuery-598"><a href="#BigQuery-598"><span class="linenos"> 598</span></a> <span class="p">}</span> -</span><span id="BigQuery-599"><a href="#BigQuery-599"><span class="linenos"> 599</span></a> -</span><span id="BigQuery-600"><a href="#BigQuery-600"><span class="linenos"> 600</span></a> <span class="n">BRACKET_OFFSETS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-601"><a href="#BigQuery-601"><span class="linenos"> 601</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> -</span><span id="BigQuery-602"><a href="#BigQuery-602"><span class="linenos"> 602</span></a> <span class="s2">"ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> -</span><span id="BigQuery-603"><a href="#BigQuery-603"><span class="linenos"> 603</span></a> <span class="s2">"SAFE_OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="BigQuery-604"><a href="#BigQuery-604"><span class="linenos"> 604</span></a> <span class="s2">"SAFE_ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="BigQuery-605"><a href="#BigQuery-605"><span class="linenos"> 605</span></a> <span class="p">}</span> -</span><span id="BigQuery-606"><a href="#BigQuery-606"><span class="linenos"> 606</span></a> -</span><span id="BigQuery-607"><a href="#BigQuery-607"><span class="linenos"> 607</span></a> <span class="k">def</span> <span class="nf">_parse_for_in</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">:</span> -</span><span id="BigQuery-608"><a href="#BigQuery-608"><span class="linenos"> 608</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">()</span> -</span><span id="BigQuery-609"><a href="#BigQuery-609"><span class="linenos"> 609</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="BigQuery-610"><a href="#BigQuery-610"><span class="linenos"> 610</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span 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_statement</span><span class="p">())</span> -</span><span id="BigQuery-611"><a href="#BigQuery-611"><span class="linenos"> 611</span></a> -</span><span id="BigQuery-612"><a href="#BigQuery-612"><span class="linenos"> 612</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="BigQuery-613"><a href="#BigQuery-613"><span class="linenos"> 613</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="BigQuery-614"><a href="#BigQuery-614"><span class="linenos"> 614</span></a> -</span><span id="BigQuery-615"><a href="#BigQuery-615"><span class="linenos"> 615</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> -</span><span id="BigQuery-616"><a href="#BigQuery-616"><span class="linenos"> 616</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> -</span><span id="BigQuery-617"><a href="#BigQuery-617"><span class="linenos"> 617</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="BigQuery-618"><a href="#BigQuery-618"><span class="linenos"> 618</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="BigQuery-619"><a href="#BigQuery-619"><span class="linenos"> 619</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="BigQuery-620"><a href="#BigQuery-620"><span class="linenos"> 620</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</span><span class="p">()</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="o">!=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">:</span> -</span><span id="BigQuery-621"><a href="#BigQuery-621"><span class="linenos"> 621</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="BigQuery-622"><a href="#BigQuery-622"><span class="linenos"> 622</span></a> <span class="n">text</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="BigQuery-623"><a href="#BigQuery-623"><span class="linenos"> 623</span></a> <span class="n">table_name</span> <span class="o">+=</span> <span class="n">text</span> -</span><span id="BigQuery-624"><a href="#BigQuery-624"><span class="linenos"> 624</span></a> -</span><span id="BigQuery-625"><a href="#BigQuery-625"><span class="linenos"> 625</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> -</span><span id="BigQuery-626"><a href="#BigQuery-626"><span class="linenos"> 626</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">Literal</span><span class="p">):</span> -</span><span id="BigQuery-627"><a href="#BigQuery-627"><span class="linenos"> 627</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="BigQuery-593"><a href="#BigQuery-593"><span class="linenos"> 593</span></a> <span class="n">DASHED_TABLE_PART_FOLLOW_TOKENS</span> <span class="o">=</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">L_PAREN</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="BigQuery-594"><a href="#BigQuery-594"><span class="linenos"> 594</span></a> +</span><span id="BigQuery-595"><a href="#BigQuery-595"><span class="linenos"> 595</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-596"><a href="#BigQuery-596"><span class="linenos"> 596</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> +</span><span id="BigQuery-597"><a href="#BigQuery-597"><span class="linenos"> 597</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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="BigQuery-598"><a href="#BigQuery-598"><span class="linenos"> 598</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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="BigQuery-599"><a href="#BigQuery-599"><span class="linenos"> 599</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">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">_parse_for_in</span><span class="p">(),</span> +</span><span id="BigQuery-600"><a href="#BigQuery-600"><span class="linenos"> 600</span></a> <span class="p">}</span> +</span><span id="BigQuery-601"><a href="#BigQuery-601"><span class="linenos"> 601</span></a> +</span><span id="BigQuery-602"><a href="#BigQuery-602"><span class="linenos"> 602</span></a> <span class="n">BRACKET_OFFSETS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-603"><a href="#BigQuery-603"><span class="linenos"> 603</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> +</span><span id="BigQuery-604"><a href="#BigQuery-604"><span class="linenos"> 604</span></a> <span class="s2">"ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> +</span><span id="BigQuery-605"><a href="#BigQuery-605"><span class="linenos"> 605</span></a> <span class="s2">"SAFE_OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="BigQuery-606"><a href="#BigQuery-606"><span class="linenos"> 606</span></a> <span class="s2">"SAFE_ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="BigQuery-607"><a href="#BigQuery-607"><span class="linenos"> 607</span></a> <span class="p">}</span> +</span><span id="BigQuery-608"><a href="#BigQuery-608"><span class="linenos"> 608</span></a> +</span><span id="BigQuery-609"><a href="#BigQuery-609"><span class="linenos"> 609</span></a> <span class="k">def</span> <span class="nf">_parse_for_in</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">:</span> +</span><span id="BigQuery-610"><a href="#BigQuery-610"><span class="linenos"> 610</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">()</span> +</span><span id="BigQuery-611"><a href="#BigQuery-611"><span class="linenos"> 611</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="BigQuery-612"><a href="#BigQuery-612"><span class="linenos"> 612</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span 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_statement</span><span class="p">())</span> +</span><span id="BigQuery-613"><a href="#BigQuery-613"><span class="linenos"> 613</span></a> +</span><span id="BigQuery-614"><a href="#BigQuery-614"><span class="linenos"> 614</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="BigQuery-615"><a href="#BigQuery-615"><span class="linenos"> 615</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="BigQuery-616"><a href="#BigQuery-616"><span class="linenos"> 616</span></a> +</span><span id="BigQuery-617"><a href="#BigQuery-617"><span class="linenos"> 617</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> +</span><span id="BigQuery-618"><a href="#BigQuery-618"><span class="linenos"> 618</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> +</span><span id="BigQuery-619"><a href="#BigQuery-619"><span class="linenos"> 619</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="BigQuery-620"><a href="#BigQuery-620"><span class="linenos"> 620</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="BigQuery-621"><a href="#BigQuery-621"><span class="linenos"> 621</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="BigQuery-622"><a href="#BigQuery-622"><span class="linenos"> 622</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</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_set</span><span class="p">(</span> +</span><span id="BigQuery-623"><a href="#BigQuery-623"><span class="linenos"> 623</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">DASHED_TABLE_PART_FOLLOW_TOKENS</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span> +</span><span id="BigQuery-624"><a href="#BigQuery-624"><span class="linenos"> 624</span></a> <span class="p">):</span> +</span><span id="BigQuery-625"><a href="#BigQuery-625"><span class="linenos"> 625</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="BigQuery-626"><a href="#BigQuery-626"><span class="linenos"> 626</span></a> +</span><span id="BigQuery-627"><a href="#BigQuery-627"><span class="linenos"> 627</span></a> <span class="n">table_name</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="BigQuery-628"><a href="#BigQuery-628"><span class="linenos"> 628</span></a> -</span><span id="BigQuery-629"><a href="#BigQuery-629"><span class="linenos"> 629</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</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 class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="BigQuery-630"><a href="#BigQuery-630"><span class="linenos"> 630</span></a> <span class="n">table_name</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="BigQuery-631"><a href="#BigQuery-631"><span class="linenos"> 631</span></a> -</span><span id="BigQuery-632"><a href="#BigQuery-632"><span class="linenos"> 632</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="BigQuery-633"><a href="#BigQuery-633"><span class="linenos"> 633</span></a> -</span><span id="BigQuery-634"><a href="#BigQuery-634"><span class="linenos"> 634</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="BigQuery-629"><a href="#BigQuery-629"><span class="linenos"> 629</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> +</span><span id="BigQuery-630"><a href="#BigQuery-630"><span class="linenos"> 630</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">Literal</span><span class="p">):</span> +</span><span id="BigQuery-631"><a href="#BigQuery-631"><span class="linenos"> 631</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="BigQuery-632"><a href="#BigQuery-632"><span class="linenos"> 632</span></a> +</span><span id="BigQuery-633"><a href="#BigQuery-633"><span class="linenos"> 633</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</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 class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="BigQuery-634"><a href="#BigQuery-634"><span class="linenos"> 634</span></a> <span class="n">table_name</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="BigQuery-635"><a href="#BigQuery-635"><span class="linenos"> 635</span></a> -</span><span id="BigQuery-636"><a href="#BigQuery-636"><span class="linenos"> 636</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span> -</span><span id="BigQuery-637"><a href="#BigQuery-637"><span class="linenos"> 637</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">is_db_reference</span><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">wildcard</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-638"><a href="#BigQuery-638"><span class="linenos"> 638</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="BigQuery-639"><a href="#BigQuery-639"><span class="linenos"> 639</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span> -</span><span id="BigQuery-640"><a href="#BigQuery-640"><span class="linenos"> 640</span></a> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">,</span> <span class="n">is_db_reference</span><span class="o">=</span><span class="n">is_db_reference</span><span class="p">,</span> <span class="n">wildcard</span><span class="o">=</span><span class="kc">True</span> -</span><span id="BigQuery-641"><a href="#BigQuery-641"><span class="linenos"> 641</span></a> <span class="p">)</span> -</span><span id="BigQuery-642"><a href="#BigQuery-642"><span class="linenos"> 642</span></a> -</span><span id="BigQuery-643"><a href="#BigQuery-643"><span class="linenos"> 643</span></a> <span class="c1"># proj-1.db.tbl -- `1.` is tokenized as a float so we need to unravel it here</span> -</span><span id="BigQuery-644"><a href="#BigQuery-644"><span class="linenos"> 644</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">catalog</span><span class="p">:</span> -</span><span id="BigQuery-645"><a href="#BigQuery-645"><span class="linenos"> 645</span></a> <span class="k">if</span> <span class="n">table</span><span class="o">.</span><span class="n">db</span><span class="p">:</span> -</span><span id="BigQuery-646"><a href="#BigQuery-646"><span class="linenos"> 646</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">db</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="BigQuery-647"><a href="#BigQuery-647"><span class="linenos"> 647</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"db"</span><span class="p">]</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> -</span><span id="BigQuery-648"><a href="#BigQuery-648"><span class="linenos"> 648</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> -</span><span id="BigQuery-649"><a href="#BigQuery-649"><span class="linenos"> 649</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> -</span><span id="BigQuery-650"><a href="#BigQuery-650"><span class="linenos"> 650</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="BigQuery-651"><a href="#BigQuery-651"><span class="linenos"> 651</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">name</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="BigQuery-652"><a href="#BigQuery-652"><span class="linenos"> 652</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> -</span><span id="BigQuery-653"><a href="#BigQuery-653"><span class="linenos"> 653</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> -</span><span id="BigQuery-654"><a href="#BigQuery-654"><span class="linenos"> 654</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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="BigQuery-655"><a href="#BigQuery-655"><span class="linenos"> 655</span></a> -</span><span id="BigQuery-656"><a href="#BigQuery-656"><span class="linenos"> 656</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">):</span> -</span><span id="BigQuery-657"><a href="#BigQuery-657"><span class="linenos"> 657</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery-658"><a href="#BigQuery-658"><span class="linenos"> 658</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="BigQuery-659"><a href="#BigQuery-659"><span class="linenos"> 659</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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="BigQuery-660"><a href="#BigQuery-660"><span class="linenos"> 660</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> -</span><span id="BigQuery-661"><a href="#BigQuery-661"><span class="linenos"> 661</span></a> <span class="p">)</span> -</span><span id="BigQuery-662"><a href="#BigQuery-662"><span class="linenos"> 662</span></a> -</span><span id="BigQuery-663"><a href="#BigQuery-663"><span class="linenos"> 663</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> -</span><span id="BigQuery-664"><a href="#BigQuery-664"><span class="linenos"> 664</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> -</span><span id="BigQuery-665"><a href="#BigQuery-665"><span class="linenos"> 665</span></a> -</span><span id="BigQuery-666"><a href="#BigQuery-666"><span class="linenos"> 666</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span> -</span><span id="BigQuery-667"><a href="#BigQuery-667"><span class="linenos"> 667</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">)</span> -</span><span id="BigQuery-668"><a href="#BigQuery-668"><span class="linenos"> 668</span></a> <span class="p">)</span> -</span><span id="BigQuery-669"><a href="#BigQuery-669"><span class="linenos"> 669</span></a> <span class="n">table</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_table"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-670"><a href="#BigQuery-670"><span class="linenos"> 670</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="BigQuery-671"><a href="#BigQuery-671"><span class="linenos"> 671</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="BigQuery-672"><a href="#BigQuery-672"><span class="linenos"> 672</span></a> -</span><span id="BigQuery-673"><a href="#BigQuery-673"><span class="linenos"> 673</span></a> <span class="c1"># The `INFORMATION_SCHEMA` views in BigQuery need to be qualified by a region or</span> -</span><span id="BigQuery-674"><a href="#BigQuery-674"><span class="linenos"> 674</span></a> <span class="c1"># dataset, so if the project identifier is omitted we need to fix the ast so that</span> -</span><span id="BigQuery-675"><a href="#BigQuery-675"><span class="linenos"> 675</span></a> <span class="c1"># the `INFORMATION_SCHEMA.X` bit is represented as a single (quoted) Identifier.</span> -</span><span id="BigQuery-676"><a href="#BigQuery-676"><span class="linenos"> 676</span></a> <span class="c1"># Otherwise, we wouldn't correctly qualify a `Table` node that references these</span> -</span><span id="BigQuery-677"><a href="#BigQuery-677"><span class="linenos"> 677</span></a> <span class="c1"># views, because it would seem like the "catalog" part is set, when it'd actually</span> -</span><span id="BigQuery-678"><a href="#BigQuery-678"><span class="linenos"> 678</span></a> <span class="c1"># be the region/dataset. Merging the two identifiers into a single one is done to</span> -</span><span id="BigQuery-679"><a href="#BigQuery-679"><span class="linenos"> 679</span></a> <span class="c1"># avoid producing a 4-part Table reference, which would cause issues in the schema</span> -</span><span id="BigQuery-680"><a href="#BigQuery-680"><span class="linenos"> 680</span></a> <span class="c1"># module, when there are 3-part table names mixed with information schema views.</span> -</span><span id="BigQuery-681"><a href="#BigQuery-681"><span class="linenos"> 681</span></a> <span class="c1">#</span> -</span><span id="BigQuery-682"><a href="#BigQuery-682"><span class="linenos"> 682</span></a> <span class="c1"># See: https://cloud.google.com/bigquery/docs/information-schema-intro#syntax</span> -</span><span id="BigQuery-683"><a href="#BigQuery-683"><span class="linenos"> 683</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span> -</span><span id="BigQuery-684"><a href="#BigQuery-684"><span class="linenos"> 684</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">table_parts</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"INFORMATION_SCHEMA"</span><span class="p">:</span> -</span><span id="BigQuery-685"><a href="#BigQuery-685"><span class="linenos"> 685</span></a> <span class="c1"># We need to alias the table here to avoid breaking existing qualified columns.</span> -</span><span id="BigQuery-686"><a href="#BigQuery-686"><span class="linenos"> 686</span></a> <span class="c1"># This is expected to be safe, because if there's an actual alias coming up in</span> -</span><span id="BigQuery-687"><a href="#BigQuery-687"><span class="linenos"> 687</span></a> <span class="c1"># the token stream, it will overwrite this one. If there isn't one, we are only</span> -</span><span id="BigQuery-688"><a href="#BigQuery-688"><span class="linenos"> 688</span></a> <span class="c1"># exposing the name that can be used to reference the view explicitly (a no-op).</span> -</span><span id="BigQuery-689"><a href="#BigQuery-689"><span class="linenos"> 689</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span> -</span><span id="BigQuery-690"><a href="#BigQuery-690"><span class="linenos"> 690</span></a> <span class="n">table</span><span class="p">,</span> -</span><span id="BigQuery-691"><a href="#BigQuery-691"><span class="linenos"> 691</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">Identifier</span><span class="p">,</span> <span class="n">alias</span> <span class="ow">or</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]),</span> -</span><span id="BigQuery-692"><a href="#BigQuery-692"><span class="linenos"> 692</span></a> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="BigQuery-693"><a href="#BigQuery-693"><span class="linenos"> 693</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="BigQuery-694"><a href="#BigQuery-694"><span class="linenos"> 694</span></a> <span class="p">)</span> -</span><span id="BigQuery-695"><a href="#BigQuery-695"><span class="linenos"> 695</span></a> -</span><span id="BigQuery-696"><a href="#BigQuery-696"><span class="linenos"> 696</span></a> <span class="n">info_schema_view</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">table_parts</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">name</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery-697"><a href="#BigQuery-697"><span class="linenos"> 697</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">info_schema_view</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="BigQuery-698"><a href="#BigQuery-698"><span class="linenos"> 698</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">))</span> -</span><span id="BigQuery-699"><a href="#BigQuery-699"><span class="linenos"> 699</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">4</span><span class="p">))</span> -</span><span id="BigQuery-700"><a href="#BigQuery-700"><span class="linenos"> 700</span></a> -</span><span id="BigQuery-701"><a href="#BigQuery-701"><span class="linenos"> 701</span></a> <span class="k">return</span> <span class="n">table</span> -</span><span id="BigQuery-702"><a href="#BigQuery-702"><span class="linenos"> 702</span></a> -</span><span id="BigQuery-703"><a href="#BigQuery-703"><span class="linenos"> 703</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="BigQuery-704"><a href="#BigQuery-704"><span class="linenos"> 704</span></a> <span class="n">column</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="BigQuery-705"><a href="#BigQuery-705"><span class="linenos"> 705</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="BigQuery-706"><a href="#BigQuery-706"><span class="linenos"> 706</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span> -</span><span id="BigQuery-707"><a href="#BigQuery-707"><span class="linenos"> 707</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">):</span> -</span><span id="BigQuery-708"><a href="#BigQuery-708"><span class="linenos"> 708</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="BigQuery-709"><a href="#BigQuery-709"><span class="linenos"> 709</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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="BigQuery-710"><a href="#BigQuery-710"><span class="linenos"> 710</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> -</span><span id="BigQuery-711"><a href="#BigQuery-711"><span class="linenos"> 711</span></a> <span class="p">)</span> -</span><span id="BigQuery-712"><a href="#BigQuery-712"><span class="linenos"> 712</span></a> -</span><span id="BigQuery-713"><a href="#BigQuery-713"><span class="linenos"> 713</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> -</span><span id="BigQuery-714"><a href="#BigQuery-714"><span class="linenos"> 714</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> -</span><span id="BigQuery-715"><a href="#BigQuery-715"><span class="linenos"> 715</span></a> -</span><span id="BigQuery-716"><a href="#BigQuery-716"><span class="linenos"> 716</span></a> <span class="n">column</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">table</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><span id="BigQuery-717"><a href="#BigQuery-717"><span class="linenos"> 717</span></a> <span class="n">column</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_column"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-718"><a href="#BigQuery-718"><span class="linenos"> 718</span></a> -</span><span id="BigQuery-719"><a href="#BigQuery-719"><span class="linenos"> 719</span></a> <span class="k">return</span> <span class="n">column</span> -</span><span id="BigQuery-720"><a href="#BigQuery-720"><span class="linenos"> 720</span></a> -</span><span id="BigQuery-721"><a href="#BigQuery-721"><span class="linenos"> 721</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="BigQuery-722"><a href="#BigQuery-722"><span class="linenos"> 722</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObject</span><span class="p">:</span> <span class="o">...</span> -</span><span id="BigQuery-723"><a href="#BigQuery-723"><span class="linenos"> 723</span></a> -</span><span id="BigQuery-724"><a href="#BigQuery-724"><span class="linenos"> 724</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="BigQuery-725"><a href="#BigQuery-725"><span class="linenos"> 725</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObjectAgg</span><span class="p">:</span> <span class="o">...</span> -</span><span id="BigQuery-726"><a href="#BigQuery-726"><span class="linenos"> 726</span></a> -</span><span id="BigQuery-727"><a href="#BigQuery-727"><span class="linenos"> 727</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="n">agg</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> -</span><span id="BigQuery-728"><a href="#BigQuery-728"><span class="linenos"> 728</span></a> <span class="n">json_object</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_json_object</span><span class="p">()</span> -</span><span id="BigQuery-729"><a href="#BigQuery-729"><span class="linenos"> 729</span></a> <span class="n">array_kv_pair</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">json_object</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="BigQuery-636"><a href="#BigQuery-636"><span class="linenos"> 636</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="BigQuery-637"><a href="#BigQuery-637"><span class="linenos"> 637</span></a> +</span><span id="BigQuery-638"><a href="#BigQuery-638"><span class="linenos"> 638</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="BigQuery-639"><a href="#BigQuery-639"><span class="linenos"> 639</span></a> +</span><span id="BigQuery-640"><a href="#BigQuery-640"><span class="linenos"> 640</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span> +</span><span id="BigQuery-641"><a href="#BigQuery-641"><span class="linenos"> 641</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">is_db_reference</span><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">wildcard</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-642"><a href="#BigQuery-642"><span class="linenos"> 642</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="BigQuery-643"><a href="#BigQuery-643"><span class="linenos"> 643</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span> +</span><span id="BigQuery-644"><a href="#BigQuery-644"><span class="linenos"> 644</span></a> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">,</span> <span class="n">is_db_reference</span><span class="o">=</span><span class="n">is_db_reference</span><span class="p">,</span> <span class="n">wildcard</span><span class="o">=</span><span class="kc">True</span> +</span><span id="BigQuery-645"><a href="#BigQuery-645"><span class="linenos"> 645</span></a> <span class="p">)</span> +</span><span id="BigQuery-646"><a href="#BigQuery-646"><span class="linenos"> 646</span></a> +</span><span id="BigQuery-647"><a href="#BigQuery-647"><span class="linenos"> 647</span></a> <span class="c1"># proj-1.db.tbl -- `1.` is tokenized as a float so we need to unravel it here</span> +</span><span id="BigQuery-648"><a href="#BigQuery-648"><span class="linenos"> 648</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">catalog</span><span class="p">:</span> +</span><span id="BigQuery-649"><a href="#BigQuery-649"><span class="linenos"> 649</span></a> <span class="k">if</span> <span class="n">table</span><span class="o">.</span><span class="n">db</span><span class="p">:</span> +</span><span id="BigQuery-650"><a href="#BigQuery-650"><span class="linenos"> 650</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">db</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="BigQuery-651"><a href="#BigQuery-651"><span class="linenos"> 651</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"db"</span><span class="p">]</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> +</span><span id="BigQuery-652"><a href="#BigQuery-652"><span class="linenos"> 652</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> +</span><span id="BigQuery-653"><a href="#BigQuery-653"><span class="linenos"> 653</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> +</span><span id="BigQuery-654"><a href="#BigQuery-654"><span class="linenos"> 654</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="BigQuery-655"><a href="#BigQuery-655"><span class="linenos"> 655</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">name</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="BigQuery-656"><a href="#BigQuery-656"><span class="linenos"> 656</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> +</span><span id="BigQuery-657"><a href="#BigQuery-657"><span class="linenos"> 657</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> +</span><span id="BigQuery-658"><a href="#BigQuery-658"><span class="linenos"> 658</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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="BigQuery-659"><a href="#BigQuery-659"><span class="linenos"> 659</span></a> +</span><span id="BigQuery-660"><a href="#BigQuery-660"><span class="linenos"> 660</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">):</span> +</span><span id="BigQuery-661"><a href="#BigQuery-661"><span class="linenos"> 661</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery-662"><a href="#BigQuery-662"><span class="linenos"> 662</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="BigQuery-663"><a href="#BigQuery-663"><span class="linenos"> 663</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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="BigQuery-664"><a href="#BigQuery-664"><span class="linenos"> 664</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> +</span><span id="BigQuery-665"><a href="#BigQuery-665"><span class="linenos"> 665</span></a> <span class="p">)</span> +</span><span id="BigQuery-666"><a href="#BigQuery-666"><span class="linenos"> 666</span></a> +</span><span id="BigQuery-667"><a href="#BigQuery-667"><span class="linenos"> 667</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> +</span><span id="BigQuery-668"><a href="#BigQuery-668"><span class="linenos"> 668</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> +</span><span id="BigQuery-669"><a href="#BigQuery-669"><span class="linenos"> 669</span></a> +</span><span id="BigQuery-670"><a href="#BigQuery-670"><span class="linenos"> 670</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span> +</span><span id="BigQuery-671"><a href="#BigQuery-671"><span class="linenos"> 671</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">)</span> +</span><span id="BigQuery-672"><a href="#BigQuery-672"><span class="linenos"> 672</span></a> <span class="p">)</span> +</span><span id="BigQuery-673"><a href="#BigQuery-673"><span class="linenos"> 673</span></a> <span class="n">table</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_table"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-674"><a href="#BigQuery-674"><span class="linenos"> 674</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="BigQuery-675"><a href="#BigQuery-675"><span class="linenos"> 675</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="BigQuery-676"><a href="#BigQuery-676"><span class="linenos"> 676</span></a> +</span><span id="BigQuery-677"><a href="#BigQuery-677"><span class="linenos"> 677</span></a> <span class="c1"># The `INFORMATION_SCHEMA` views in BigQuery need to be qualified by a region or</span> +</span><span id="BigQuery-678"><a href="#BigQuery-678"><span class="linenos"> 678</span></a> <span class="c1"># dataset, so if the project identifier is omitted we need to fix the ast so that</span> +</span><span id="BigQuery-679"><a href="#BigQuery-679"><span class="linenos"> 679</span></a> <span class="c1"># the `INFORMATION_SCHEMA.X` bit is represented as a single (quoted) Identifier.</span> +</span><span id="BigQuery-680"><a href="#BigQuery-680"><span class="linenos"> 680</span></a> <span class="c1"># Otherwise, we wouldn't correctly qualify a `Table` node that references these</span> +</span><span id="BigQuery-681"><a href="#BigQuery-681"><span class="linenos"> 681</span></a> <span class="c1"># views, because it would seem like the "catalog" part is set, when it'd actually</span> +</span><span id="BigQuery-682"><a href="#BigQuery-682"><span class="linenos"> 682</span></a> <span class="c1"># be the region/dataset. Merging the two identifiers into a single one is done to</span> +</span><span id="BigQuery-683"><a href="#BigQuery-683"><span class="linenos"> 683</span></a> <span class="c1"># avoid producing a 4-part Table reference, which would cause issues in the schema</span> +</span><span id="BigQuery-684"><a href="#BigQuery-684"><span class="linenos"> 684</span></a> <span class="c1"># module, when there are 3-part table names mixed with information schema views.</span> +</span><span id="BigQuery-685"><a href="#BigQuery-685"><span class="linenos"> 685</span></a> <span class="c1">#</span> +</span><span id="BigQuery-686"><a href="#BigQuery-686"><span class="linenos"> 686</span></a> <span class="c1"># See: https://cloud.google.com/bigquery/docs/information-schema-intro#syntax</span> +</span><span id="BigQuery-687"><a href="#BigQuery-687"><span class="linenos"> 687</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span> +</span><span id="BigQuery-688"><a href="#BigQuery-688"><span class="linenos"> 688</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">table_parts</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"INFORMATION_SCHEMA"</span><span class="p">:</span> +</span><span id="BigQuery-689"><a href="#BigQuery-689"><span class="linenos"> 689</span></a> <span class="c1"># We need to alias the table here to avoid breaking existing qualified columns.</span> +</span><span id="BigQuery-690"><a href="#BigQuery-690"><span class="linenos"> 690</span></a> <span class="c1"># This is expected to be safe, because if there's an actual alias coming up in</span> +</span><span id="BigQuery-691"><a href="#BigQuery-691"><span class="linenos"> 691</span></a> <span class="c1"># the token stream, it will overwrite this one. If there isn't one, we are only</span> +</span><span id="BigQuery-692"><a href="#BigQuery-692"><span class="linenos"> 692</span></a> <span class="c1"># exposing the name that can be used to reference the view explicitly (a no-op).</span> +</span><span id="BigQuery-693"><a href="#BigQuery-693"><span class="linenos"> 693</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span> +</span><span id="BigQuery-694"><a href="#BigQuery-694"><span class="linenos"> 694</span></a> <span class="n">table</span><span class="p">,</span> +</span><span id="BigQuery-695"><a href="#BigQuery-695"><span class="linenos"> 695</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">Identifier</span><span class="p">,</span> <span class="n">alias</span> <span class="ow">or</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]),</span> +</span><span id="BigQuery-696"><a href="#BigQuery-696"><span class="linenos"> 696</span></a> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="BigQuery-697"><a href="#BigQuery-697"><span class="linenos"> 697</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="BigQuery-698"><a href="#BigQuery-698"><span class="linenos"> 698</span></a> <span class="p">)</span> +</span><span id="BigQuery-699"><a href="#BigQuery-699"><span class="linenos"> 699</span></a> +</span><span id="BigQuery-700"><a href="#BigQuery-700"><span class="linenos"> 700</span></a> <span class="n">info_schema_view</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">table_parts</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">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-701"><a href="#BigQuery-701"><span class="linenos"> 701</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">info_schema_view</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="BigQuery-702"><a href="#BigQuery-702"><span class="linenos"> 702</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">))</span> +</span><span id="BigQuery-703"><a href="#BigQuery-703"><span class="linenos"> 703</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">4</span><span class="p">))</span> +</span><span id="BigQuery-704"><a href="#BigQuery-704"><span class="linenos"> 704</span></a> +</span><span id="BigQuery-705"><a href="#BigQuery-705"><span class="linenos"> 705</span></a> <span class="k">return</span> <span class="n">table</span> +</span><span id="BigQuery-706"><a href="#BigQuery-706"><span class="linenos"> 706</span></a> +</span><span id="BigQuery-707"><a href="#BigQuery-707"><span class="linenos"> 707</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="BigQuery-708"><a href="#BigQuery-708"><span class="linenos"> 708</span></a> <span class="n">column</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="BigQuery-709"><a href="#BigQuery-709"><span class="linenos"> 709</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="BigQuery-710"><a href="#BigQuery-710"><span class="linenos"> 710</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span> +</span><span id="BigQuery-711"><a href="#BigQuery-711"><span class="linenos"> 711</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">):</span> +</span><span id="BigQuery-712"><a href="#BigQuery-712"><span class="linenos"> 712</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="BigQuery-713"><a href="#BigQuery-713"><span class="linenos"> 713</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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="BigQuery-714"><a href="#BigQuery-714"><span class="linenos"> 714</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> +</span><span id="BigQuery-715"><a href="#BigQuery-715"><span class="linenos"> 715</span></a> <span class="p">)</span> +</span><span id="BigQuery-716"><a href="#BigQuery-716"><span class="linenos"> 716</span></a> +</span><span id="BigQuery-717"><a href="#BigQuery-717"><span class="linenos"> 717</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> +</span><span id="BigQuery-718"><a href="#BigQuery-718"><span class="linenos"> 718</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> +</span><span id="BigQuery-719"><a href="#BigQuery-719"><span class="linenos"> 719</span></a> +</span><span id="BigQuery-720"><a href="#BigQuery-720"><span class="linenos"> 720</span></a> <span class="n">column</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">table</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><span id="BigQuery-721"><a href="#BigQuery-721"><span class="linenos"> 721</span></a> <span class="n">column</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_column"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-722"><a href="#BigQuery-722"><span class="linenos"> 722</span></a> +</span><span id="BigQuery-723"><a href="#BigQuery-723"><span class="linenos"> 723</span></a> <span class="k">return</span> <span class="n">column</span> +</span><span id="BigQuery-724"><a href="#BigQuery-724"><span class="linenos"> 724</span></a> +</span><span id="BigQuery-725"><a href="#BigQuery-725"><span class="linenos"> 725</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="BigQuery-726"><a href="#BigQuery-726"><span class="linenos"> 726</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObject</span><span class="p">:</span> <span class="o">...</span> +</span><span id="BigQuery-727"><a href="#BigQuery-727"><span class="linenos"> 727</span></a> +</span><span id="BigQuery-728"><a href="#BigQuery-728"><span class="linenos"> 728</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="BigQuery-729"><a href="#BigQuery-729"><span class="linenos"> 729</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObjectAgg</span><span class="p">:</span> <span class="o">...</span> </span><span id="BigQuery-730"><a href="#BigQuery-730"><span class="linenos"> 730</span></a> -</span><span id="BigQuery-731"><a href="#BigQuery-731"><span class="linenos"> 731</span></a> <span class="c1"># Converts BQ's "signature 2" of JSON_OBJECT into SQLGlot's canonical representation</span> -</span><span id="BigQuery-732"><a href="#BigQuery-732"><span class="linenos"> 732</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#json_object_signature2</span> -</span><span id="BigQuery-733"><a href="#BigQuery-733"><span class="linenos"> 733</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="BigQuery-734"><a href="#BigQuery-734"><span class="linenos"> 734</span></a> <span class="n">array_kv_pair</span> -</span><span id="BigQuery-735"><a href="#BigQuery-735"><span class="linenos"> 735</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> -</span><span id="BigQuery-736"><a href="#BigQuery-736"><span class="linenos"> 736</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span 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><span id="BigQuery-737"><a href="#BigQuery-737"><span class="linenos"> 737</span></a> <span class="p">):</span> -</span><span id="BigQuery-738"><a href="#BigQuery-738"><span class="linenos"> 738</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="BigQuery-739"><a href="#BigQuery-739"><span class="linenos"> 739</span></a> <span class="n">values</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="BigQuery-740"><a href="#BigQuery-740"><span class="linenos"> 740</span></a> -</span><span id="BigQuery-741"><a href="#BigQuery-741"><span class="linenos"> 741</span></a> <span class="n">json_object</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="BigQuery-742"><a href="#BigQuery-742"><span class="linenos"> 742</span></a> <span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="BigQuery-743"><a href="#BigQuery-743"><span class="linenos"> 743</span></a> <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">k</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">values</span><span class="p">)],</span> -</span><span id="BigQuery-744"><a href="#BigQuery-744"><span class="linenos"> 744</span></a> <span class="p">)</span> -</span><span id="BigQuery-745"><a href="#BigQuery-745"><span class="linenos"> 745</span></a> -</span><span id="BigQuery-746"><a href="#BigQuery-746"><span class="linenos"> 746</span></a> <span class="k">return</span> <span class="n">json_object</span> -</span><span id="BigQuery-747"><a href="#BigQuery-747"><span class="linenos"> 747</span></a> -</span><span id="BigQuery-748"><a href="#BigQuery-748"><span class="linenos"> 748</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> -</span><span id="BigQuery-749"><a href="#BigQuery-749"><span class="linenos"> 749</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="BigQuery-750"><a href="#BigQuery-750"><span class="linenos"> 750</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="BigQuery-751"><a href="#BigQuery-751"><span class="linenos"> 751</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="BigQuery-752"><a href="#BigQuery-752"><span class="linenos"> 752</span></a> -</span><span id="BigQuery-753"><a href="#BigQuery-753"><span class="linenos"> 753</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">is</span> <span class="n">bracket</span><span class="p">:</span> -</span><span id="BigQuery-754"><a href="#BigQuery-754"><span class="linenos"> 754</span></a> <span class="k">return</span> <span class="n">bracket</span> -</span><span id="BigQuery-755"><a href="#BigQuery-755"><span class="linenos"> 755</span></a> -</span><span id="BigQuery-756"><a href="#BigQuery-756"><span class="linenos"> 756</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> -</span><span id="BigQuery-757"><a href="#BigQuery-757"><span class="linenos"> 757</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">bracket</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="BigQuery-758"><a href="#BigQuery-758"><span class="linenos"> 758</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="BigQuery-731"><a href="#BigQuery-731"><span class="linenos"> 731</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="n">agg</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> +</span><span id="BigQuery-732"><a href="#BigQuery-732"><span class="linenos"> 732</span></a> <span class="n">json_object</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_json_object</span><span class="p">()</span> +</span><span id="BigQuery-733"><a href="#BigQuery-733"><span class="linenos"> 733</span></a> <span class="n">array_kv_pair</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">json_object</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="BigQuery-734"><a href="#BigQuery-734"><span class="linenos"> 734</span></a> +</span><span id="BigQuery-735"><a href="#BigQuery-735"><span class="linenos"> 735</span></a> <span class="c1"># Converts BQ's "signature 2" of JSON_OBJECT into SQLGlot's canonical representation</span> +</span><span id="BigQuery-736"><a href="#BigQuery-736"><span class="linenos"> 736</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#json_object_signature2</span> +</span><span id="BigQuery-737"><a href="#BigQuery-737"><span class="linenos"> 737</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="BigQuery-738"><a href="#BigQuery-738"><span class="linenos"> 738</span></a> <span class="n">array_kv_pair</span> +</span><span id="BigQuery-739"><a href="#BigQuery-739"><span class="linenos"> 739</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> +</span><span id="BigQuery-740"><a href="#BigQuery-740"><span class="linenos"> 740</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span 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><span id="BigQuery-741"><a href="#BigQuery-741"><span class="linenos"> 741</span></a> <span class="p">):</span> +</span><span id="BigQuery-742"><a href="#BigQuery-742"><span class="linenos"> 742</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery-743"><a href="#BigQuery-743"><span class="linenos"> 743</span></a> <span class="n">values</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery-744"><a href="#BigQuery-744"><span class="linenos"> 744</span></a> +</span><span id="BigQuery-745"><a href="#BigQuery-745"><span class="linenos"> 745</span></a> <span class="n">json_object</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="BigQuery-746"><a href="#BigQuery-746"><span class="linenos"> 746</span></a> <span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="BigQuery-747"><a href="#BigQuery-747"><span class="linenos"> 747</span></a> <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">k</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">values</span><span class="p">)],</span> +</span><span id="BigQuery-748"><a href="#BigQuery-748"><span class="linenos"> 748</span></a> <span class="p">)</span> +</span><span id="BigQuery-749"><a href="#BigQuery-749"><span class="linenos"> 749</span></a> +</span><span id="BigQuery-750"><a href="#BigQuery-750"><span class="linenos"> 750</span></a> <span class="k">return</span> <span class="n">json_object</span> +</span><span id="BigQuery-751"><a href="#BigQuery-751"><span class="linenos"> 751</span></a> +</span><span id="BigQuery-752"><a href="#BigQuery-752"><span class="linenos"> 752</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> +</span><span id="BigQuery-753"><a href="#BigQuery-753"><span class="linenos"> 753</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="BigQuery-754"><a href="#BigQuery-754"><span class="linenos"> 754</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="BigQuery-755"><a href="#BigQuery-755"><span class="linenos"> 755</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="BigQuery-756"><a href="#BigQuery-756"><span class="linenos"> 756</span></a> +</span><span id="BigQuery-757"><a href="#BigQuery-757"><span class="linenos"> 757</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">is</span> <span class="n">bracket</span><span class="p">:</span> +</span><span id="BigQuery-758"><a href="#BigQuery-758"><span class="linenos"> 758</span></a> <span class="k">return</span> <span class="n">bracket</span> </span><span id="BigQuery-759"><a href="#BigQuery-759"><span class="linenos"> 759</span></a> -</span><span id="BigQuery-760"><a href="#BigQuery-760"><span class="linenos"> 760</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">:</span> -</span><span id="BigQuery-761"><a href="#BigQuery-761"><span class="linenos"> 761</span></a> <span class="k">break</span> -</span><span id="BigQuery-762"><a href="#BigQuery-762"><span class="linenos"> 762</span></a> -</span><span id="BigQuery-763"><a href="#BigQuery-763"><span class="linenos"> 763</span></a> <span class="n">offset</span><span class="p">,</span> <span class="n">safe</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> -</span><span id="BigQuery-764"><a href="#BigQuery-764"><span class="linenos"> 764</span></a> <span class="n">bracket</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">offset</span><span class="p">)</span> -</span><span id="BigQuery-765"><a href="#BigQuery-765"><span class="linenos"> 765</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">,</span> <span class="n">safe</span><span class="p">)</span> -</span><span id="BigQuery-766"><a href="#BigQuery-766"><span class="linenos"> 766</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> -</span><span id="BigQuery-767"><a href="#BigQuery-767"><span class="linenos"> 767</span></a> -</span><span id="BigQuery-768"><a href="#BigQuery-768"><span class="linenos"> 768</span></a> <span class="k">return</span> <span class="n">bracket</span> -</span><span id="BigQuery-769"><a href="#BigQuery-769"><span class="linenos"> 769</span></a> -</span><span id="BigQuery-770"><a href="#BigQuery-770"><span class="linenos"> 770</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="BigQuery-771"><a href="#BigQuery-771"><span class="linenos"> 771</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</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="n">with_alias</span><span class="p">)</span> -</span><span id="BigQuery-772"><a href="#BigQuery-772"><span class="linenos"> 772</span></a> -</span><span id="BigQuery-773"><a href="#BigQuery-773"><span class="linenos"> 773</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="BigQuery-774"><a href="#BigQuery-774"><span class="linenos"> 774</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="BigQuery-775"><a href="#BigQuery-775"><span class="linenos"> 775</span></a> -</span><span id="BigQuery-776"><a href="#BigQuery-776"><span class="linenos"> 776</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">unnest</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="BigQuery-777"><a href="#BigQuery-777"><span class="linenos"> 777</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="p">:</span> -</span><span id="BigQuery-778"><a href="#BigQuery-778"><span class="linenos"> 778</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="BigQuery-760"><a href="#BigQuery-760"><span class="linenos"> 760</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> +</span><span id="BigQuery-761"><a href="#BigQuery-761"><span class="linenos"> 761</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">bracket</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="BigQuery-762"><a href="#BigQuery-762"><span class="linenos"> 762</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="BigQuery-763"><a href="#BigQuery-763"><span class="linenos"> 763</span></a> +</span><span id="BigQuery-764"><a href="#BigQuery-764"><span class="linenos"> 764</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">:</span> +</span><span id="BigQuery-765"><a href="#BigQuery-765"><span class="linenos"> 765</span></a> <span class="k">break</span> +</span><span id="BigQuery-766"><a href="#BigQuery-766"><span class="linenos"> 766</span></a> +</span><span id="BigQuery-767"><a href="#BigQuery-767"><span class="linenos"> 767</span></a> <span class="n">offset</span><span class="p">,</span> <span class="n">safe</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> +</span><span id="BigQuery-768"><a href="#BigQuery-768"><span class="linenos"> 768</span></a> <span class="n">bracket</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">offset</span><span class="p">)</span> +</span><span id="BigQuery-769"><a href="#BigQuery-769"><span class="linenos"> 769</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">,</span> <span class="n">safe</span><span class="p">)</span> +</span><span id="BigQuery-770"><a href="#BigQuery-770"><span class="linenos"> 770</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="BigQuery-771"><a href="#BigQuery-771"><span class="linenos"> 771</span></a> +</span><span id="BigQuery-772"><a href="#BigQuery-772"><span class="linenos"> 772</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="BigQuery-773"><a href="#BigQuery-773"><span class="linenos"> 773</span></a> +</span><span id="BigQuery-774"><a href="#BigQuery-774"><span class="linenos"> 774</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="BigQuery-775"><a href="#BigQuery-775"><span class="linenos"> 775</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</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="n">with_alias</span><span class="p">)</span> +</span><span id="BigQuery-776"><a href="#BigQuery-776"><span class="linenos"> 776</span></a> +</span><span id="BigQuery-777"><a href="#BigQuery-777"><span class="linenos"> 777</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="BigQuery-778"><a href="#BigQuery-778"><span class="linenos"> 778</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="BigQuery-779"><a href="#BigQuery-779"><span class="linenos"> 779</span></a> -</span><span id="BigQuery-780"><a href="#BigQuery-780"><span class="linenos"> 780</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">unnest_expr</span><span class="p">)</span> -</span><span id="BigQuery-781"><a href="#BigQuery-781"><span class="linenos"> 781</span></a> -</span><span id="BigQuery-782"><a href="#BigQuery-782"><span class="linenos"> 782</span></a> <span class="c1"># Unnesting a nested array (i.e array of structs) explodes the top-level struct fields,</span> -</span><span id="BigQuery-783"><a href="#BigQuery-783"><span class="linenos"> 783</span></a> <span class="c1"># in contrast to other dialects such as DuckDB which flattens only the array by default</span> -</span><span id="BigQuery-784"><a href="#BigQuery-784"><span class="linenos"> 784</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span> -</span><span id="BigQuery-785"><a href="#BigQuery-785"><span class="linenos"> 785</span></a> <span class="n">array_elem</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">)</span> -</span><span id="BigQuery-786"><a href="#BigQuery-786"><span class="linenos"> 786</span></a> <span class="k">for</span> <span class="n">array_elem</span> <span class="ow">in</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">_type</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="BigQuery-787"><a href="#BigQuery-787"><span class="linenos"> 787</span></a> <span class="p">):</span> -</span><span id="BigQuery-788"><a href="#BigQuery-788"><span class="linenos"> 788</span></a> <span class="n">unnest</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"explode_array"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> -</span><span id="BigQuery-789"><a href="#BigQuery-789"><span class="linenos"> 789</span></a> -</span><span id="BigQuery-790"><a href="#BigQuery-790"><span class="linenos"> 790</span></a> <span class="k">return</span> <span class="n">unnest</span> -</span><span id="BigQuery-791"><a href="#BigQuery-791"><span class="linenos"> 791</span></a> -</span><span id="BigQuery-792"><a href="#BigQuery-792"><span class="linenos"> 792</span></a> <span class="k">def</span> <span class="nf">_parse_make_interval</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">:</span> -</span><span id="BigQuery-793"><a href="#BigQuery-793"><span class="linenos"> 793</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">()</span> -</span><span id="BigQuery-794"><a href="#BigQuery-794"><span class="linenos"> 794</span></a> -</span><span id="BigQuery-795"><a href="#BigQuery-795"><span class="linenos"> 795</span></a> <span class="k">for</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="n">expr</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> -</span><span id="BigQuery-796"><a href="#BigQuery-796"><span class="linenos"> 796</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> -</span><span id="BigQuery-797"><a href="#BigQuery-797"><span class="linenos"> 797</span></a> -</span><span id="BigQuery-798"><a href="#BigQuery-798"><span class="linenos"> 798</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> -</span><span id="BigQuery-799"><a href="#BigQuery-799"><span class="linenos"> 799</span></a> <span class="k">break</span> -</span><span id="BigQuery-800"><a href="#BigQuery-800"><span class="linenos"> 800</span></a> -</span><span id="BigQuery-801"><a href="#BigQuery-801"><span class="linenos"> 801</span></a> <span class="c1"># Non-named arguments are filled sequentially, (optionally) followed by named arguments</span> -</span><span id="BigQuery-802"><a href="#BigQuery-802"><span class="linenos"> 802</span></a> <span class="c1"># that can appear in any order e.g MAKE_INTERVAL(1, minute => 5, day => 2)</span> -</span><span id="BigQuery-803"><a href="#BigQuery-803"><span class="linenos"> 803</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">):</span> -</span><span id="BigQuery-804"><a href="#BigQuery-804"><span class="linenos"> 804</span></a> <span class="n">arg_key</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="BigQuery-805"><a href="#BigQuery-805"><span class="linenos"> 805</span></a> -</span><span id="BigQuery-806"><a href="#BigQuery-806"><span class="linenos"> 806</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg_key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> -</span><span id="BigQuery-807"><a href="#BigQuery-807"><span class="linenos"> 807</span></a> -</span><span id="BigQuery-808"><a href="#BigQuery-808"><span class="linenos"> 808</span></a> <span class="bp">self</span><span 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="BigQuery-780"><a href="#BigQuery-780"><span class="linenos"> 780</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">unnest</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="BigQuery-781"><a href="#BigQuery-781"><span class="linenos"> 781</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="p">:</span> +</span><span id="BigQuery-782"><a href="#BigQuery-782"><span class="linenos"> 782</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="BigQuery-783"><a href="#BigQuery-783"><span class="linenos"> 783</span></a> +</span><span id="BigQuery-784"><a href="#BigQuery-784"><span class="linenos"> 784</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">unnest_expr</span><span class="p">)</span> +</span><span id="BigQuery-785"><a href="#BigQuery-785"><span class="linenos"> 785</span></a> +</span><span id="BigQuery-786"><a href="#BigQuery-786"><span class="linenos"> 786</span></a> <span class="c1"># Unnesting a nested array (i.e array of structs) explodes the top-level struct fields,</span> +</span><span id="BigQuery-787"><a href="#BigQuery-787"><span class="linenos"> 787</span></a> <span class="c1"># in contrast to other dialects such as DuckDB which flattens only the array by default</span> +</span><span id="BigQuery-788"><a href="#BigQuery-788"><span class="linenos"> 788</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span> +</span><span id="BigQuery-789"><a href="#BigQuery-789"><span class="linenos"> 789</span></a> <span class="n">array_elem</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">)</span> +</span><span id="BigQuery-790"><a href="#BigQuery-790"><span class="linenos"> 790</span></a> <span class="k">for</span> <span class="n">array_elem</span> <span class="ow">in</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">_type</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery-791"><a href="#BigQuery-791"><span class="linenos"> 791</span></a> <span class="p">):</span> +</span><span id="BigQuery-792"><a href="#BigQuery-792"><span class="linenos"> 792</span></a> <span class="n">unnest</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"explode_array"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> +</span><span id="BigQuery-793"><a href="#BigQuery-793"><span class="linenos"> 793</span></a> +</span><span id="BigQuery-794"><a href="#BigQuery-794"><span class="linenos"> 794</span></a> <span class="k">return</span> <span class="n">unnest</span> +</span><span id="BigQuery-795"><a href="#BigQuery-795"><span class="linenos"> 795</span></a> +</span><span id="BigQuery-796"><a href="#BigQuery-796"><span class="linenos"> 796</span></a> <span class="k">def</span> <span class="nf">_parse_make_interval</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">:</span> +</span><span id="BigQuery-797"><a href="#BigQuery-797"><span class="linenos"> 797</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">()</span> +</span><span id="BigQuery-798"><a href="#BigQuery-798"><span class="linenos"> 798</span></a> +</span><span id="BigQuery-799"><a href="#BigQuery-799"><span class="linenos"> 799</span></a> <span class="k">for</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="n">expr</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> +</span><span id="BigQuery-800"><a href="#BigQuery-800"><span class="linenos"> 800</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> +</span><span id="BigQuery-801"><a href="#BigQuery-801"><span class="linenos"> 801</span></a> +</span><span id="BigQuery-802"><a href="#BigQuery-802"><span class="linenos"> 802</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> +</span><span id="BigQuery-803"><a href="#BigQuery-803"><span class="linenos"> 803</span></a> <span class="k">break</span> +</span><span id="BigQuery-804"><a href="#BigQuery-804"><span class="linenos"> 804</span></a> +</span><span id="BigQuery-805"><a href="#BigQuery-805"><span class="linenos"> 805</span></a> <span class="c1"># Non-named arguments are filled sequentially, (optionally) followed by named arguments</span> +</span><span id="BigQuery-806"><a href="#BigQuery-806"><span class="linenos"> 806</span></a> <span class="c1"># that can appear in any order e.g MAKE_INTERVAL(1, minute => 5, day => 2)</span> +</span><span id="BigQuery-807"><a href="#BigQuery-807"><span class="linenos"> 807</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">):</span> +</span><span id="BigQuery-808"><a href="#BigQuery-808"><span class="linenos"> 808</span></a> <span class="n">arg_key</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> </span><span id="BigQuery-809"><a href="#BigQuery-809"><span class="linenos"> 809</span></a> -</span><span id="BigQuery-810"><a href="#BigQuery-810"><span class="linenos"> 810</span></a> <span class="k">return</span> <span class="n">expr</span> +</span><span id="BigQuery-810"><a href="#BigQuery-810"><span class="linenos"> 810</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg_key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> </span><span id="BigQuery-811"><a href="#BigQuery-811"><span class="linenos"> 811</span></a> -</span><span id="BigQuery-812"><a href="#BigQuery-812"><span class="linenos"> 812</span></a> <span class="k">def</span> <span class="nf">_parse_features_at_time</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">:</span> -</span><span id="BigQuery-813"><a href="#BigQuery-813"><span class="linenos"> 813</span></a> <span class="n">expr</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="BigQuery-814"><a href="#BigQuery-814"><span class="linenos"> 814</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">,</span> -</span><span id="BigQuery-815"><a href="#BigQuery-815"><span class="linenos"> 815</span></a> <span class="n">this</span><span class="o">=</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">TABLE</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="BigQuery-816"><a href="#BigQuery-816"><span class="linenos"> 816</span></a> <span class="ow">or</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="BigQuery-817"><a href="#BigQuery-817"><span class="linenos"> 817</span></a> <span class="p">)</span> -</span><span id="BigQuery-818"><a href="#BigQuery-818"><span class="linenos"> 818</span></a> -</span><span id="BigQuery-819"><a href="#BigQuery-819"><span class="linenos"> 819</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">COMMA</span><span class="p">):</span> -</span><span id="BigQuery-820"><a href="#BigQuery-820"><span class="linenos"> 820</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> -</span><span id="BigQuery-821"><a href="#BigQuery-821"><span class="linenos"> 821</span></a> -</span><span id="BigQuery-822"><a href="#BigQuery-822"><span class="linenos"> 822</span></a> <span class="c1"># Get the LHS of the Kwarg and set the arg to that value, e.g</span> -</span><span id="BigQuery-823"><a href="#BigQuery-823"><span class="linenos"> 823</span></a> <span class="c1"># "num_rows => 1" sets the expr's `num_rows` arg</span> -</span><span id="BigQuery-824"><a href="#BigQuery-824"><span class="linenos"> 824</span></a> <span class="k">if</span> <span class="n">arg</span><span class="p">:</span> -</span><span id="BigQuery-825"><a href="#BigQuery-825"><span class="linenos"> 825</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> -</span><span id="BigQuery-826"><a href="#BigQuery-826"><span class="linenos"> 826</span></a> -</span><span id="BigQuery-827"><a href="#BigQuery-827"><span class="linenos"> 827</span></a> <span class="k">return</span> <span class="n">expr</span> -</span><span id="BigQuery-828"><a href="#BigQuery-828"><span class="linenos"> 828</span></a> -</span><span id="BigQuery-829"><a href="#BigQuery-829"><span class="linenos"> 829</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="BigQuery-830"><a href="#BigQuery-830"><span class="linenos"> 830</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-831"><a href="#BigQuery-831"><span class="linenos"> 831</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-832"><a href="#BigQuery-832"><span class="linenos"> 832</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-833"><a href="#BigQuery-833"><span class="linenos"> 833</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-834"><a href="#BigQuery-834"><span class="linenos"> 834</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="BigQuery-835"><a href="#BigQuery-835"><span class="linenos"> 835</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-836"><a href="#BigQuery-836"><span class="linenos"> 836</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-837"><a href="#BigQuery-837"><span class="linenos"> 837</span></a> <span class="n">UNNEST_WITH_ORDINALITY</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-838"><a href="#BigQuery-838"><span class="linenos"> 838</span></a> <span class="n">COLLATE_IS_FUNC</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-839"><a href="#BigQuery-839"><span class="linenos"> 839</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-840"><a href="#BigQuery-840"><span class="linenos"> 840</span></a> <span class="n">SUPPORTS_TABLE_ALIAS_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-841"><a href="#BigQuery-841"><span class="linenos"> 841</span></a> <span class="n">UNPIVOT_ALIASES_ARE_IDENTIFIERS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-842"><a href="#BigQuery-842"><span class="linenos"> 842</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> -</span><span id="BigQuery-843"><a href="#BigQuery-843"><span class="linenos"> 843</span></a> <span class="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-844"><a href="#BigQuery-844"><span class="linenos"> 844</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-845"><a href="#BigQuery-845"><span class="linenos"> 845</span></a> <span class="n">JSON_PATH_SINGLE_QUOTE_ESCAPE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-846"><a href="#BigQuery-846"><span class="linenos"> 846</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-847"><a href="#BigQuery-847"><span class="linenos"> 847</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-848"><a href="#BigQuery-848"><span class="linenos"> 848</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> -</span><span id="BigQuery-849"><a href="#BigQuery-849"><span class="linenos"> 849</span></a> <span class="n">HEX_FUNC</span> <span class="o">=</span> <span class="s2">"TO_HEX"</span> -</span><span id="BigQuery-850"><a href="#BigQuery-850"><span class="linenos"> 850</span></a> <span class="n">WITH_PROPERTIES_PREFIX</span> <span class="o">=</span> <span class="s2">"OPTIONS"</span> -</span><span id="BigQuery-851"><a href="#BigQuery-851"><span class="linenos"> 851</span></a> <span class="n">SUPPORTS_EXPLODING_PROJECTIONS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-852"><a href="#BigQuery-852"><span class="linenos"> 852</span></a> <span class="n">EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-853"><a href="#BigQuery-853"><span class="linenos"> 853</span></a> <span class="n">SUPPORTS_UNIX_SECONDS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-854"><a href="#BigQuery-854"><span class="linenos"> 854</span></a> -</span><span id="BigQuery-855"><a href="#BigQuery-855"><span class="linenos"> 855</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-856"><a href="#BigQuery-856"><span class="linenos"> 856</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="BigQuery-857"><a href="#BigQuery-857"><span class="linenos"> 857</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> -</span><span id="BigQuery-858"><a href="#BigQuery-858"><span class="linenos"> 858</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> -</span><span id="BigQuery-859"><a href="#BigQuery-859"><span class="linenos"> 859</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> -</span><span id="BigQuery-860"><a href="#BigQuery-860"><span class="linenos"> 860</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> -</span><span id="BigQuery-861"><a href="#BigQuery-861"><span class="linenos"> 861</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">_array_contains_sql</span><span class="p">,</span> -</span><span id="BigQuery-862"><a href="#BigQuery-862"><span class="linenos"> 862</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">filter_array_using_unnest</span><span class="p">,</span> -</span><span id="BigQuery-863"><a href="#BigQuery-863"><span class="linenos"> 863</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_precision_parameterized_types</span><span class="p">]),</span> -</span><span id="BigQuery-864"><a href="#BigQuery-864"><span class="linenos"> 864</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> -</span><span id="BigQuery-865"><a href="#BigQuery-865"><span class="linenos"> 865</span></a> <span class="sa">f</span><span class="s2">"DEFAULT COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery-866"><a href="#BigQuery-866"><span class="linenos"> 866</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> -</span><span id="BigQuery-867"><a href="#BigQuery-867"><span class="linenos"> 867</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery-868"><a href="#BigQuery-868"><span class="linenos"> 868</span></a> <span class="p">),</span> -</span><span id="BigQuery-869"><a href="#BigQuery-869"><span class="linenos"> 869</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"COMMIT TRANSACTION"</span><span class="p">,</span> -</span><span id="BigQuery-870"><a href="#BigQuery-870"><span class="linenos"> 870</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COUNTIF"</span><span class="p">),</span> -</span><span id="BigQuery-871"><a href="#BigQuery-871"><span class="linenos"> 871</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> -</span><span id="BigQuery-872"><a href="#BigQuery-872"><span class="linenos"> 872</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_pushdown_cte_column_names</span><span class="p">]),</span> -</span><span id="BigQuery-873"><a href="#BigQuery-873"><span class="linenos"> 873</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery-874"><a href="#BigQuery-874"><span class="linenos"> 874</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery-875"><a href="#BigQuery-875"><span class="linenos"> 875</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">unit_to_var</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="BigQuery-876"><a href="#BigQuery-876"><span class="linenos"> 876</span></a> <span class="p">),</span> -</span><span id="BigQuery-877"><a href="#BigQuery-877"><span class="linenos"> 877</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">),</span> -</span><span id="BigQuery-878"><a href="#BigQuery-878"><span class="linenos"> 878</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> -</span><span id="BigQuery-879"><a href="#BigQuery-879"><span class="linenos"> 879</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery-880"><a href="#BigQuery-880"><span class="linenos"> 880</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery-881"><a href="#BigQuery-881"><span class="linenos"> 881</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery-882"><a href="#BigQuery-882"><span class="linenos"> 882</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery-883"><a href="#BigQuery-883"><span class="linenos"> 883</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)</span> -</span><span id="BigQuery-884"><a href="#BigQuery-884"><span class="linenos"> 884</span></a> <span class="p">),</span> -</span><span id="BigQuery-885"><a href="#BigQuery-885"><span class="linenos"> 885</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromTimeZone</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery-886"><a href="#BigQuery-886"><span class="linenos"> 886</span></a> <span class="s2">"DATETIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)),</span> <span class="s2">"'UTC'"</span> -</span><span id="BigQuery-887"><a href="#BigQuery-887"><span class="linenos"> 887</span></a> <span class="p">),</span> -</span><span id="BigQuery-888"><a href="#BigQuery-888"><span class="linenos"> 888</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GENERATE_ARRAY"</span><span class="p">),</span> -</span><span id="BigQuery-889"><a href="#BigQuery-889"><span class="linenos"> 889</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> -</span><span id="BigQuery-890"><a href="#BigQuery-890"><span class="linenos"> 890</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> -</span><span id="BigQuery-891"><a href="#BigQuery-891"><span class="linenos"> 891</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(</span><span class="n">false_value</span><span class="o">=</span><span class="s2">"NULL"</span><span class="p">),</span> -</span><span id="BigQuery-892"><a href="#BigQuery-892"><span class="linenos"> 892</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="BigQuery-893"><a href="#BigQuery-893"><span class="linenos"> 893</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> -</span><span id="BigQuery-894"><a href="#BigQuery-894"><span class="linenos"> 894</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Int64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"INT64"</span><span class="p">),</span> -</span><span id="BigQuery-895"><a href="#BigQuery-895"><span class="linenos"> 895</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> -</span><span id="BigQuery-896"><a href="#BigQuery-896"><span class="linenos"> 896</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractArray</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> -</span><span id="BigQuery-897"><a href="#BigQuery-897"><span class="linenos"> 897</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> -</span><span id="BigQuery-898"><a href="#BigQuery-898"><span class="linenos"> 898</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_JSON_STRING"</span><span class="p">),</span> -</span><span id="BigQuery-899"><a href="#BigQuery-899"><span class="linenos"> 899</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">_levenshtein_sql</span><span class="p">,</span> -</span><span id="BigQuery-900"><a href="#BigQuery-900"><span class="linenos"> 900</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="BigQuery-901"><a href="#BigQuery-901"><span class="linenos"> 901</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> -</span><span id="BigQuery-902"><a href="#BigQuery-902"><span class="linenos"> 902</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">),</span> -</span><span id="BigQuery-903"><a href="#BigQuery-903"><span class="linenos"> 903</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="BigQuery-904"><a href="#BigQuery-904"><span class="linenos"> 904</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="BigQuery-905"><a href="#BigQuery-905"><span class="linenos"> 905</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery-906"><a href="#BigQuery-906"><span class="linenos"> 906</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> -</span><span id="BigQuery-907"><a href="#BigQuery-907"><span class="linenos"> 907</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="BigQuery-908"><a href="#BigQuery-908"><span class="linenos"> 908</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="BigQuery-909"><a href="#BigQuery-909"><span class="linenos"> 909</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">),</span> -</span><span id="BigQuery-910"><a href="#BigQuery-910"><span class="linenos"> 910</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"occurrence"</span><span class="p">),</span> -</span><span id="BigQuery-911"><a href="#BigQuery-911"><span class="linenos"> 911</span></a> <span class="p">),</span> -</span><span id="BigQuery-912"><a href="#BigQuery-912"><span class="linenos"> 912</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtractAll</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery-913"><a href="#BigQuery-913"><span class="linenos"> 913</span></a> <span class="s2">"REGEXP_EXTRACT_ALL"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span> -</span><span id="BigQuery-914"><a href="#BigQuery-914"><span class="linenos"> 914</span></a> <span class="p">),</span> -</span><span id="BigQuery-915"><a href="#BigQuery-915"><span class="linenos"> 915</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="n">regexp_replace_sql</span><span class="p">,</span> -</span><span id="BigQuery-916"><a href="#BigQuery-916"><span class="linenos"> 916</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_CONTAINS"</span><span class="p">),</span> -</span><span id="BigQuery-917"><a href="#BigQuery-917"><span class="linenos"> 917</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> -</span><span id="BigQuery-918"><a href="#BigQuery-918"><span class="linenos"> 918</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"ROLLBACK TRANSACTION"</span><span class="p">,</span> -</span><span id="BigQuery-919"><a href="#BigQuery-919"><span class="linenos"> 919</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="BigQuery-920"><a href="#BigQuery-920"><span class="linenos"> 920</span></a> <span class="p">[</span> -</span><span id="BigQuery-921"><a href="#BigQuery-921"><span class="linenos"> 921</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(),</span> -</span><span id="BigQuery-922"><a href="#BigQuery-922"><span class="linenos"> 922</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> -</span><span id="BigQuery-923"><a href="#BigQuery-923"><span class="linenos"> 923</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="BigQuery-924"><a href="#BigQuery-924"><span class="linenos"> 924</span></a> <span class="n">_alias_ordered_group</span><span class="p">,</span> -</span><span id="BigQuery-925"><a href="#BigQuery-925"><span class="linenos"> 925</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">,</span> -</span><span id="BigQuery-926"><a href="#BigQuery-926"><span class="linenos"> 926</span></a> <span class="p">]</span> -</span><span id="BigQuery-927"><a href="#BigQuery-927"><span class="linenos"> 927</span></a> <span class="p">),</span> -</span><span id="BigQuery-928"><a href="#BigQuery-928"><span class="linenos"> 928</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SHA1"</span><span class="p">),</span> -</span><span id="BigQuery-929"><a href="#BigQuery-929"><span class="linenos"> 929</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA2</span><span class="p">:</span> <span class="n">sha256_sql</span><span class="p">,</span> -</span><span id="BigQuery-930"><a href="#BigQuery-930"><span class="linenos"> 930</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> -</span><span id="BigQuery-931"><a href="#BigQuery-931"><span class="linenos"> 931</span></a> <span class="s2">"DETERMINISTIC"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span> -</span><span id="BigQuery-932"><a href="#BigQuery-932"><span class="linenos"> 932</span></a> <span class="p">),</span> -</span><span id="BigQuery-933"><a href="#BigQuery-933"><span class="linenos"> 933</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">String</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING"</span><span class="p">),</span> -</span><span id="BigQuery-934"><a href="#BigQuery-934"><span class="linenos"> 934</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> -</span><span id="BigQuery-935"><a href="#BigQuery-935"><span class="linenos"> 935</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> -</span><span id="BigQuery-936"><a href="#BigQuery-936"><span class="linenos"> 936</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> -</span><span id="BigQuery-937"><a href="#BigQuery-937"><span class="linenos"> 937</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery-938"><a href="#BigQuery-938"><span class="linenos"> 938</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> -</span><span id="BigQuery-939"><a href="#BigQuery-939"><span class="linenos"> 939</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> -</span><span id="BigQuery-940"><a href="#BigQuery-940"><span class="linenos"> 940</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery-941"><a href="#BigQuery-941"><span class="linenos"> 941</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery-942"><a href="#BigQuery-942"><span class="linenos"> 942</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP_DIFF"</span><span class="p">),</span> -</span><span id="BigQuery-943"><a href="#BigQuery-943"><span class="linenos"> 943</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery-944"><a href="#BigQuery-944"><span class="linenos"> 944</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="BigQuery-945"><a href="#BigQuery-945"><span class="linenos"> 945</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">,</span> -</span><span id="BigQuery-946"><a href="#BigQuery-946"><span class="linenos"> 946</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="BigQuery-947"><a href="#BigQuery-947"><span class="linenos"> 947</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">_ts_or_ds_diff_sql</span><span class="p">,</span> -</span><span id="BigQuery-948"><a href="#BigQuery-948"><span class="linenos"> 948</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> -</span><span id="BigQuery-949"><a href="#BigQuery-949"><span class="linenos"> 949</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> -</span><span id="BigQuery-950"><a href="#BigQuery-950"><span class="linenos"> 950</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">),</span> -</span><span id="BigQuery-951"><a href="#BigQuery-951"><span class="linenos"> 951</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> -</span><span id="BigQuery-952"><a href="#BigQuery-952"><span class="linenos"> 952</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_DATE"</span><span class="p">),</span> -</span><span id="BigQuery-953"><a href="#BigQuery-953"><span class="linenos"> 953</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> -</span><span id="BigQuery-954"><a href="#BigQuery-954"><span class="linenos"> 954</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uuid</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"GENERATE_UUID()"</span><span class="p">,</span> -</span><span id="BigQuery-955"><a href="#BigQuery-955"><span class="linenos"> 955</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> -</span><span id="BigQuery-956"><a href="#BigQuery-956"><span class="linenos"> 956</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> -</span><span id="BigQuery-957"><a href="#BigQuery-957"><span class="linenos"> 957</span></a> <span class="p">}</span> -</span><span id="BigQuery-958"><a href="#BigQuery-958"><span class="linenos"> 958</span></a> -</span><span id="BigQuery-959"><a href="#BigQuery-959"><span class="linenos"> 959</span></a> <span class="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-960"><a href="#BigQuery-960"><span class="linenos"> 960</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> -</span><span id="BigQuery-961"><a href="#BigQuery-961"><span class="linenos"> 961</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> -</span><span id="BigQuery-962"><a href="#BigQuery-962"><span class="linenos"> 962</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> -</span><span id="BigQuery-963"><a href="#BigQuery-963"><span class="linenos"> 963</span></a> <span class="p">}</span> -</span><span id="BigQuery-964"><a href="#BigQuery-964"><span class="linenos"> 964</span></a> -</span><span id="BigQuery-965"><a href="#BigQuery-965"><span class="linenos"> 965</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-966"><a href="#BigQuery-966"><span class="linenos"> 966</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="BigQuery-967"><a href="#BigQuery-967"><span class="linenos"> 967</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> -</span><span id="BigQuery-968"><a href="#BigQuery-968"><span class="linenos"> 968</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery-969"><a href="#BigQuery-969"><span class="linenos"> 969</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery-970"><a href="#BigQuery-970"><span class="linenos"> 970</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> -</span><span id="BigQuery-971"><a href="#BigQuery-971"><span class="linenos"> 971</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-972"><a href="#BigQuery-972"><span class="linenos"> 972</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">:</span> <span class="s2">"NUMERIC"</span><span class="p">,</span> -</span><span id="BigQuery-973"><a href="#BigQuery-973"><span class="linenos"> 973</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> -</span><span id="BigQuery-974"><a href="#BigQuery-974"><span class="linenos"> 974</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> -</span><span id="BigQuery-975"><a href="#BigQuery-975"><span class="linenos"> 975</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery-976"><a href="#BigQuery-976"><span class="linenos"> 976</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-977"><a href="#BigQuery-977"><span class="linenos"> 977</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-978"><a href="#BigQuery-978"><span class="linenos"> 978</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery-979"><a href="#BigQuery-979"><span class="linenos"> 979</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-980"><a href="#BigQuery-980"><span class="linenos"> 980</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> -</span><span id="BigQuery-981"><a href="#BigQuery-981"><span class="linenos"> 981</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="BigQuery-982"><a href="#BigQuery-982"><span class="linenos"> 982</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="BigQuery-983"><a href="#BigQuery-983"><span class="linenos"> 983</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery-984"><a href="#BigQuery-984"><span class="linenos"> 984</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery-985"><a href="#BigQuery-985"><span class="linenos"> 985</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UUID</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-986"><a href="#BigQuery-986"><span class="linenos"> 986</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery-987"><a href="#BigQuery-987"><span class="linenos"> 987</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-988"><a href="#BigQuery-988"><span class="linenos"> 988</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> -</span><span id="BigQuery-989"><a href="#BigQuery-989"><span class="linenos"> 989</span></a> <span class="p">}</span> -</span><span id="BigQuery-990"><a href="#BigQuery-990"><span class="linenos"> 990</span></a> -</span><span id="BigQuery-991"><a href="#BigQuery-991"><span class="linenos"> 991</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-992"><a href="#BigQuery-992"><span class="linenos"> 992</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="BigQuery-993"><a href="#BigQuery-993"><span class="linenos"> 993</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="BigQuery-994"><a href="#BigQuery-994"><span class="linenos"> 994</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="BigQuery-995"><a href="#BigQuery-995"><span class="linenos"> 995</span></a> <span class="p">}</span> -</span><span id="BigQuery-996"><a href="#BigQuery-996"><span class="linenos"> 996</span></a> -</span><span id="BigQuery-997"><a href="#BigQuery-997"><span class="linenos"> 997</span></a> <span class="c1"># WINDOW comes after QUALIFY</span> -</span><span id="BigQuery-998"><a href="#BigQuery-998"><span class="linenos"> 998</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#window_clause</span> -</span><span id="BigQuery-999"><a href="#BigQuery-999"><span class="linenos"> 999</span></a> <span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-1000"><a href="#BigQuery-1000"><span class="linenos">1000</span></a> <span class="s2">"qualify"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"qualify"</span><span class="p">],</span> -</span><span id="BigQuery-1001"><a href="#BigQuery-1001"><span class="linenos">1001</span></a> <span class="s2">"windows"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"windows"</span><span class="p">],</span> -</span><span id="BigQuery-1002"><a href="#BigQuery-1002"><span class="linenos">1002</span></a> <span class="p">}</span> -</span><span id="BigQuery-1003"><a href="#BigQuery-1003"><span class="linenos">1003</span></a> -</span><span id="BigQuery-1004"><a href="#BigQuery-1004"><span class="linenos">1004</span></a> <span class="c1"># from: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords</span> -</span><span id="BigQuery-1005"><a href="#BigQuery-1005"><span class="linenos">1005</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-1006"><a href="#BigQuery-1006"><span class="linenos">1006</span></a> <span class="s2">"all"</span><span class="p">,</span> -</span><span id="BigQuery-1007"><a href="#BigQuery-1007"><span class="linenos">1007</span></a> <span class="s2">"and"</span><span class="p">,</span> -</span><span id="BigQuery-1008"><a href="#BigQuery-1008"><span class="linenos">1008</span></a> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="BigQuery-1009"><a href="#BigQuery-1009"><span class="linenos">1009</span></a> <span class="s2">"array"</span><span class="p">,</span> -</span><span id="BigQuery-1010"><a href="#BigQuery-1010"><span class="linenos">1010</span></a> <span class="s2">"as"</span><span class="p">,</span> -</span><span id="BigQuery-1011"><a href="#BigQuery-1011"><span class="linenos">1011</span></a> <span class="s2">"asc"</span><span class="p">,</span> -</span><span id="BigQuery-1012"><a href="#BigQuery-1012"><span class="linenos">1012</span></a> <span class="s2">"assert_rows_modified"</span><span class="p">,</span> -</span><span id="BigQuery-1013"><a href="#BigQuery-1013"><span class="linenos">1013</span></a> <span class="s2">"at"</span><span class="p">,</span> -</span><span id="BigQuery-1014"><a href="#BigQuery-1014"><span class="linenos">1014</span></a> <span class="s2">"between"</span><span class="p">,</span> -</span><span id="BigQuery-1015"><a href="#BigQuery-1015"><span class="linenos">1015</span></a> <span class="s2">"by"</span><span class="p">,</span> -</span><span id="BigQuery-1016"><a href="#BigQuery-1016"><span class="linenos">1016</span></a> <span class="s2">"case"</span><span class="p">,</span> -</span><span id="BigQuery-1017"><a href="#BigQuery-1017"><span class="linenos">1017</span></a> <span class="s2">"cast"</span><span class="p">,</span> -</span><span id="BigQuery-1018"><a href="#BigQuery-1018"><span class="linenos">1018</span></a> <span class="s2">"collate"</span><span class="p">,</span> -</span><span id="BigQuery-1019"><a href="#BigQuery-1019"><span class="linenos">1019</span></a> <span class="s2">"contains"</span><span class="p">,</span> -</span><span id="BigQuery-1020"><a href="#BigQuery-1020"><span class="linenos">1020</span></a> <span class="s2">"create"</span><span class="p">,</span> -</span><span id="BigQuery-1021"><a href="#BigQuery-1021"><span class="linenos">1021</span></a> <span class="s2">"cross"</span><span class="p">,</span> -</span><span id="BigQuery-1022"><a href="#BigQuery-1022"><span class="linenos">1022</span></a> <span class="s2">"cube"</span><span class="p">,</span> -</span><span id="BigQuery-1023"><a href="#BigQuery-1023"><span class="linenos">1023</span></a> <span class="s2">"current"</span><span class="p">,</span> -</span><span id="BigQuery-1024"><a href="#BigQuery-1024"><span class="linenos">1024</span></a> <span class="s2">"default"</span><span class="p">,</span> -</span><span id="BigQuery-1025"><a href="#BigQuery-1025"><span class="linenos">1025</span></a> <span class="s2">"define"</span><span class="p">,</span> -</span><span id="BigQuery-1026"><a href="#BigQuery-1026"><span class="linenos">1026</span></a> <span class="s2">"desc"</span><span class="p">,</span> -</span><span id="BigQuery-1027"><a href="#BigQuery-1027"><span class="linenos">1027</span></a> <span class="s2">"distinct"</span><span class="p">,</span> -</span><span id="BigQuery-1028"><a href="#BigQuery-1028"><span class="linenos">1028</span></a> <span class="s2">"else"</span><span class="p">,</span> -</span><span id="BigQuery-1029"><a href="#BigQuery-1029"><span class="linenos">1029</span></a> <span class="s2">"end"</span><span class="p">,</span> -</span><span id="BigQuery-1030"><a href="#BigQuery-1030"><span class="linenos">1030</span></a> <span class="s2">"enum"</span><span class="p">,</span> -</span><span id="BigQuery-1031"><a href="#BigQuery-1031"><span class="linenos">1031</span></a> <span class="s2">"escape"</span><span class="p">,</span> -</span><span id="BigQuery-1032"><a href="#BigQuery-1032"><span class="linenos">1032</span></a> <span class="s2">"except"</span><span class="p">,</span> -</span><span id="BigQuery-1033"><a href="#BigQuery-1033"><span class="linenos">1033</span></a> <span class="s2">"exclude"</span><span class="p">,</span> -</span><span id="BigQuery-1034"><a href="#BigQuery-1034"><span class="linenos">1034</span></a> <span class="s2">"exists"</span><span class="p">,</span> -</span><span id="BigQuery-1035"><a href="#BigQuery-1035"><span class="linenos">1035</span></a> <span class="s2">"extract"</span><span class="p">,</span> -</span><span id="BigQuery-1036"><a href="#BigQuery-1036"><span class="linenos">1036</span></a> <span class="s2">"false"</span><span class="p">,</span> -</span><span id="BigQuery-1037"><a href="#BigQuery-1037"><span class="linenos">1037</span></a> <span class="s2">"fetch"</span><span class="p">,</span> -</span><span id="BigQuery-1038"><a href="#BigQuery-1038"><span class="linenos">1038</span></a> <span class="s2">"following"</span><span class="p">,</span> -</span><span id="BigQuery-1039"><a href="#BigQuery-1039"><span class="linenos">1039</span></a> <span class="s2">"for"</span><span class="p">,</span> -</span><span id="BigQuery-1040"><a href="#BigQuery-1040"><span class="linenos">1040</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="BigQuery-1041"><a href="#BigQuery-1041"><span class="linenos">1041</span></a> <span class="s2">"full"</span><span class="p">,</span> -</span><span id="BigQuery-1042"><a href="#BigQuery-1042"><span class="linenos">1042</span></a> <span class="s2">"group"</span><span class="p">,</span> -</span><span id="BigQuery-1043"><a href="#BigQuery-1043"><span class="linenos">1043</span></a> <span class="s2">"grouping"</span><span class="p">,</span> -</span><span id="BigQuery-1044"><a href="#BigQuery-1044"><span class="linenos">1044</span></a> <span class="s2">"groups"</span><span class="p">,</span> -</span><span id="BigQuery-1045"><a href="#BigQuery-1045"><span class="linenos">1045</span></a> <span class="s2">"hash"</span><span class="p">,</span> -</span><span id="BigQuery-1046"><a href="#BigQuery-1046"><span class="linenos">1046</span></a> <span class="s2">"having"</span><span class="p">,</span> -</span><span id="BigQuery-1047"><a href="#BigQuery-1047"><span class="linenos">1047</span></a> <span class="s2">"if"</span><span class="p">,</span> -</span><span id="BigQuery-1048"><a href="#BigQuery-1048"><span class="linenos">1048</span></a> <span class="s2">"ignore"</span><span class="p">,</span> -</span><span id="BigQuery-1049"><a href="#BigQuery-1049"><span class="linenos">1049</span></a> <span class="s2">"in"</span><span class="p">,</span> -</span><span id="BigQuery-1050"><a href="#BigQuery-1050"><span class="linenos">1050</span></a> <span class="s2">"inner"</span><span class="p">,</span> -</span><span id="BigQuery-1051"><a href="#BigQuery-1051"><span class="linenos">1051</span></a> <span class="s2">"intersect"</span><span class="p">,</span> -</span><span id="BigQuery-1052"><a href="#BigQuery-1052"><span class="linenos">1052</span></a> <span class="s2">"interval"</span><span class="p">,</span> -</span><span id="BigQuery-1053"><a href="#BigQuery-1053"><span class="linenos">1053</span></a> <span class="s2">"into"</span><span class="p">,</span> -</span><span id="BigQuery-1054"><a href="#BigQuery-1054"><span class="linenos">1054</span></a> <span class="s2">"is"</span><span class="p">,</span> -</span><span id="BigQuery-1055"><a href="#BigQuery-1055"><span class="linenos">1055</span></a> <span class="s2">"join"</span><span class="p">,</span> -</span><span id="BigQuery-1056"><a href="#BigQuery-1056"><span class="linenos">1056</span></a> <span class="s2">"lateral"</span><span class="p">,</span> -</span><span id="BigQuery-1057"><a href="#BigQuery-1057"><span class="linenos">1057</span></a> <span class="s2">"left"</span><span class="p">,</span> -</span><span id="BigQuery-1058"><a href="#BigQuery-1058"><span class="linenos">1058</span></a> <span class="s2">"like"</span><span class="p">,</span> -</span><span id="BigQuery-1059"><a href="#BigQuery-1059"><span class="linenos">1059</span></a> <span class="s2">"limit"</span><span class="p">,</span> -</span><span id="BigQuery-1060"><a href="#BigQuery-1060"><span class="linenos">1060</span></a> <span class="s2">"lookup"</span><span class="p">,</span> -</span><span id="BigQuery-1061"><a href="#BigQuery-1061"><span class="linenos">1061</span></a> <span class="s2">"merge"</span><span class="p">,</span> -</span><span id="BigQuery-1062"><a href="#BigQuery-1062"><span class="linenos">1062</span></a> <span class="s2">"natural"</span><span class="p">,</span> -</span><span id="BigQuery-1063"><a href="#BigQuery-1063"><span class="linenos">1063</span></a> <span class="s2">"new"</span><span class="p">,</span> -</span><span id="BigQuery-1064"><a href="#BigQuery-1064"><span class="linenos">1064</span></a> <span class="s2">"no"</span><span class="p">,</span> -</span><span id="BigQuery-1065"><a href="#BigQuery-1065"><span class="linenos">1065</span></a> <span class="s2">"not"</span><span class="p">,</span> -</span><span id="BigQuery-1066"><a href="#BigQuery-1066"><span class="linenos">1066</span></a> <span class="s2">"null"</span><span class="p">,</span> -</span><span id="BigQuery-1067"><a href="#BigQuery-1067"><span class="linenos">1067</span></a> <span class="s2">"nulls"</span><span class="p">,</span> -</span><span id="BigQuery-1068"><a href="#BigQuery-1068"><span class="linenos">1068</span></a> <span class="s2">"of"</span><span class="p">,</span> -</span><span id="BigQuery-1069"><a href="#BigQuery-1069"><span class="linenos">1069</span></a> <span class="s2">"on"</span><span class="p">,</span> -</span><span id="BigQuery-1070"><a href="#BigQuery-1070"><span class="linenos">1070</span></a> <span class="s2">"or"</span><span class="p">,</span> -</span><span id="BigQuery-1071"><a href="#BigQuery-1071"><span class="linenos">1071</span></a> <span class="s2">"order"</span><span class="p">,</span> -</span><span id="BigQuery-1072"><a href="#BigQuery-1072"><span class="linenos">1072</span></a> <span class="s2">"outer"</span><span class="p">,</span> -</span><span id="BigQuery-1073"><a href="#BigQuery-1073"><span class="linenos">1073</span></a> <span class="s2">"over"</span><span class="p">,</span> -</span><span id="BigQuery-1074"><a href="#BigQuery-1074"><span class="linenos">1074</span></a> <span class="s2">"partition"</span><span class="p">,</span> -</span><span id="BigQuery-1075"><a href="#BigQuery-1075"><span class="linenos">1075</span></a> <span class="s2">"preceding"</span><span class="p">,</span> -</span><span id="BigQuery-1076"><a href="#BigQuery-1076"><span class="linenos">1076</span></a> <span class="s2">"proto"</span><span class="p">,</span> -</span><span id="BigQuery-1077"><a href="#BigQuery-1077"><span class="linenos">1077</span></a> <span class="s2">"qualify"</span><span class="p">,</span> -</span><span id="BigQuery-1078"><a href="#BigQuery-1078"><span class="linenos">1078</span></a> <span class="s2">"range"</span><span class="p">,</span> -</span><span id="BigQuery-1079"><a href="#BigQuery-1079"><span class="linenos">1079</span></a> <span class="s2">"recursive"</span><span class="p">,</span> -</span><span id="BigQuery-1080"><a href="#BigQuery-1080"><span class="linenos">1080</span></a> <span class="s2">"respect"</span><span class="p">,</span> -</span><span id="BigQuery-1081"><a href="#BigQuery-1081"><span class="linenos">1081</span></a> <span class="s2">"right"</span><span class="p">,</span> -</span><span id="BigQuery-1082"><a href="#BigQuery-1082"><span class="linenos">1082</span></a> <span class="s2">"rollup"</span><span class="p">,</span> -</span><span id="BigQuery-1083"><a href="#BigQuery-1083"><span class="linenos">1083</span></a> <span class="s2">"rows"</span><span class="p">,</span> -</span><span id="BigQuery-1084"><a href="#BigQuery-1084"><span class="linenos">1084</span></a> <span class="s2">"select"</span><span class="p">,</span> -</span><span id="BigQuery-1085"><a href="#BigQuery-1085"><span class="linenos">1085</span></a> <span class="s2">"set"</span><span class="p">,</span> -</span><span id="BigQuery-1086"><a href="#BigQuery-1086"><span class="linenos">1086</span></a> <span class="s2">"some"</span><span class="p">,</span> -</span><span id="BigQuery-1087"><a href="#BigQuery-1087"><span class="linenos">1087</span></a> <span class="s2">"struct"</span><span class="p">,</span> -</span><span id="BigQuery-1088"><a href="#BigQuery-1088"><span class="linenos">1088</span></a> <span class="s2">"tablesample"</span><span class="p">,</span> -</span><span id="BigQuery-1089"><a href="#BigQuery-1089"><span class="linenos">1089</span></a> <span class="s2">"then"</span><span class="p">,</span> -</span><span id="BigQuery-1090"><a href="#BigQuery-1090"><span class="linenos">1090</span></a> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="BigQuery-1091"><a href="#BigQuery-1091"><span class="linenos">1091</span></a> <span class="s2">"treat"</span><span class="p">,</span> -</span><span id="BigQuery-1092"><a href="#BigQuery-1092"><span class="linenos">1092</span></a> <span class="s2">"true"</span><span class="p">,</span> -</span><span id="BigQuery-1093"><a href="#BigQuery-1093"><span class="linenos">1093</span></a> <span class="s2">"unbounded"</span><span class="p">,</span> -</span><span id="BigQuery-1094"><a href="#BigQuery-1094"><span class="linenos">1094</span></a> <span class="s2">"union"</span><span class="p">,</span> -</span><span id="BigQuery-1095"><a href="#BigQuery-1095"><span class="linenos">1095</span></a> <span class="s2">"unnest"</span><span class="p">,</span> -</span><span id="BigQuery-1096"><a href="#BigQuery-1096"><span class="linenos">1096</span></a> <span class="s2">"using"</span><span class="p">,</span> -</span><span id="BigQuery-1097"><a href="#BigQuery-1097"><span class="linenos">1097</span></a> <span class="s2">"when"</span><span class="p">,</span> -</span><span id="BigQuery-1098"><a href="#BigQuery-1098"><span class="linenos">1098</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="BigQuery-1099"><a href="#BigQuery-1099"><span class="linenos">1099</span></a> <span class="s2">"window"</span><span class="p">,</span> -</span><span id="BigQuery-1100"><a href="#BigQuery-1100"><span class="linenos">1100</span></a> <span class="s2">"with"</span><span class="p">,</span> -</span><span id="BigQuery-1101"><a href="#BigQuery-1101"><span class="linenos">1101</span></a> <span class="s2">"within"</span><span class="p">,</span> -</span><span id="BigQuery-1102"><a href="#BigQuery-1102"><span class="linenos">1102</span></a> <span class="p">}</span> -</span><span id="BigQuery-1103"><a href="#BigQuery-1103"><span class="linenos">1103</span></a> -</span><span id="BigQuery-1104"><a href="#BigQuery-1104"><span class="linenos">1104</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1105"><a href="#BigQuery-1105"><span class="linenos">1105</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery-1106"><a href="#BigQuery-1106"><span class="linenos">1106</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="BigQuery-1107"><a href="#BigQuery-1107"><span class="linenos">1107</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery-1108"><a href="#BigQuery-1108"><span class="linenos">1108</span></a> <span class="s2">"MOD"</span><span class="p">,</span> -</span><span id="BigQuery-1109"><a href="#BigQuery-1109"><span class="linenos">1109</span></a> <span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <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">Paren</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> -</span><span id="BigQuery-1110"><a href="#BigQuery-1110"><span class="linenos">1110</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</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="k">else</span> <span class="n">expr</span><span class="p">,</span> -</span><span id="BigQuery-1111"><a href="#BigQuery-1111"><span class="linenos">1111</span></a> <span class="p">)</span> -</span><span id="BigQuery-1112"><a href="#BigQuery-1112"><span class="linenos">1112</span></a> -</span><span id="BigQuery-1113"><a href="#BigQuery-1113"><span class="linenos">1113</span></a> <span class="k">def</span> <span class="nf">column_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1114"><a href="#BigQuery-1114"><span class="linenos">1114</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_column"</span><span class="p">):</span> -</span><span id="BigQuery-1115"><a href="#BigQuery-1115"><span class="linenos">1115</span></a> <span class="c1"># If a column reference is of the form `dataset.table`.name, we need</span> -</span><span id="BigQuery-1116"><a href="#BigQuery-1116"><span class="linenos">1116</span></a> <span class="c1"># to preserve the quoted table path, otherwise the reference breaks</span> -</span><span id="BigQuery-1117"><a href="#BigQuery-1117"><span class="linenos">1117</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> -</span><span id="BigQuery-1118"><a href="#BigQuery-1118"><span class="linenos">1118</span></a> <span class="n">table_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</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="BigQuery-1119"><a href="#BigQuery-1119"><span class="linenos">1119</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_path</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery-1120"><a href="#BigQuery-1120"><span class="linenos">1120</span></a> -</span><span id="BigQuery-1121"><a href="#BigQuery-1121"><span class="linenos">1121</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">column_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery-1122"><a href="#BigQuery-1122"><span class="linenos">1122</span></a> -</span><span id="BigQuery-1123"><a href="#BigQuery-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1124"><a href="#BigQuery-1124"><span class="linenos">1124</span></a> <span class="c1"># Depending on the context, `x.y` may not resolve to the same data source as `x`.`y`, so</span> -</span><span id="BigQuery-1125"><a href="#BigQuery-1125"><span class="linenos">1125</span></a> <span class="c1"># we need to make sure the correct quoting is used in each case.</span> -</span><span id="BigQuery-1126"><a href="#BigQuery-1126"><span class="linenos">1126</span></a> <span class="c1">#</span> -</span><span id="BigQuery-1127"><a href="#BigQuery-1127"><span class="linenos">1127</span></a> <span class="c1"># For example, if there is a CTE x that clashes with a schema name, then the former will</span> -</span><span id="BigQuery-1128"><a href="#BigQuery-1128"><span class="linenos">1128</span></a> <span class="c1"># return the table y in that schema, whereas the latter will return the CTE's y column:</span> -</span><span id="BigQuery-1129"><a href="#BigQuery-1129"><span class="linenos">1129</span></a> <span class="c1">#</span> -</span><span id="BigQuery-1130"><a href="#BigQuery-1130"><span class="linenos">1130</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x.y` -> cross join</span> -</span><span id="BigQuery-1131"><a href="#BigQuery-1131"><span class="linenos">1131</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x`.`y` -> implicit unnest</span> -</span><span id="BigQuery-1132"><a href="#BigQuery-1132"><span class="linenos">1132</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_table"</span><span class="p">):</span> -</span><span id="BigQuery-1133"><a href="#BigQuery-1133"><span class="linenos">1133</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">)</span> -</span><span id="BigQuery-1134"><a href="#BigQuery-1134"><span class="linenos">1134</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="BigQuery-1135"><a href="#BigQuery-1135"><span class="linenos">1135</span></a> -</span><span id="BigQuery-1136"><a href="#BigQuery-1136"><span class="linenos">1136</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">table_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery-1137"><a href="#BigQuery-1137"><span class="linenos">1137</span></a> -</span><span id="BigQuery-1138"><a href="#BigQuery-1138"><span class="linenos">1138</span></a> <span class="k">def</span> <span class="nf">timetostr_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1139"><a href="#BigQuery-1139"><span class="linenos">1139</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery-1140"><a href="#BigQuery-1140"><span class="linenos">1140</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">TsOrDsToDatetime</span><span class="p">):</span> -</span><span id="BigQuery-1141"><a href="#BigQuery-1141"><span class="linenos">1141</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATETIME"</span> -</span><span id="BigQuery-1142"><a href="#BigQuery-1142"><span class="linenos">1142</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">TsOrDsToTimestamp</span><span class="p">):</span> -</span><span id="BigQuery-1143"><a href="#BigQuery-1143"><span class="linenos">1143</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_TIMESTAMP"</span> -</span><span id="BigQuery-1144"><a href="#BigQuery-1144"><span class="linenos">1144</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="BigQuery-1145"><a href="#BigQuery-1145"><span class="linenos">1145</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATE"</span> -</span><span id="BigQuery-1146"><a href="#BigQuery-1146"><span class="linenos">1146</span></a> -</span><span id="BigQuery-1147"><a href="#BigQuery-1147"><span class="linenos">1147</span></a> <span class="n">time_expr</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="BigQuery-1148"><a href="#BigQuery-1148"><span class="linenos">1148</span></a> <span class="n">this</span> -</span><span id="BigQuery-1149"><a href="#BigQuery-1149"><span class="linenos">1149</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="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">))</span> -</span><span id="BigQuery-1150"><a href="#BigQuery-1150"><span class="linenos">1150</span></a> <span class="k">else</span> <span class="n">expression</span> -</span><span id="BigQuery-1151"><a href="#BigQuery-1151"><span class="linenos">1151</span></a> <span class="p">)</span> -</span><span id="BigQuery-1152"><a href="#BigQuery-1152"><span class="linenos">1152</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">time_expr</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="BigQuery-1153"><a href="#BigQuery-1153"><span class="linenos">1153</span></a> -</span><span id="BigQuery-1154"><a href="#BigQuery-1154"><span class="linenos">1154</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1155"><a href="#BigQuery-1155"><span class="linenos">1155</span></a> <span class="c1"># Operands of = cannot be NULL in BigQuery</span> -</span><span id="BigQuery-1156"><a href="#BigQuery-1156"><span class="linenos">1156</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">right</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">):</span> -</span><span id="BigQuery-1157"><a href="#BigQuery-1157"><span class="linenos">1157</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="BigQuery-1158"><a href="#BigQuery-1158"><span class="linenos">1158</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> -</span><span id="BigQuery-1159"><a href="#BigQuery-1159"><span class="linenos">1159</span></a> -</span><span id="BigQuery-1160"><a href="#BigQuery-1160"><span class="linenos">1160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> -</span><span id="BigQuery-1161"><a href="#BigQuery-1161"><span class="linenos">1161</span></a> -</span><span id="BigQuery-1162"><a href="#BigQuery-1162"><span class="linenos">1162</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1163"><a href="#BigQuery-1163"><span class="linenos">1163</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> -</span><span id="BigQuery-1164"><a href="#BigQuery-1164"><span class="linenos">1164</span></a> -</span><span id="BigQuery-1165"><a href="#BigQuery-1165"><span class="linenos">1165</span></a> <span class="c1"># BigQuery allows CAST(.. AS {STRING|TIMESTAMP} [FORMAT <fmt> [AT TIME ZONE <tz>]]).</span> -</span><span id="BigQuery-1166"><a href="#BigQuery-1166"><span class="linenos">1166</span></a> <span class="c1"># Only the TIMESTAMP one should use the below conversion, when AT TIME ZONE is included.</span> -</span><span id="BigQuery-1167"><a href="#BigQuery-1167"><span class="linenos">1167</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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> -</span><span id="BigQuery-1168"><a href="#BigQuery-1168"><span class="linenos">1168</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery-1169"><a href="#BigQuery-1169"><span class="linenos">1169</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">))</span> -</span><span id="BigQuery-1170"><a href="#BigQuery-1170"><span class="linenos">1170</span></a> <span class="p">)</span> -</span><span id="BigQuery-1171"><a href="#BigQuery-1171"><span class="linenos">1171</span></a> -</span><span id="BigQuery-1172"><a href="#BigQuery-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">attimezone_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery-1173"><a href="#BigQuery-1173"><span class="linenos">1173</span></a> -</span><span id="BigQuery-1174"><a href="#BigQuery-1174"><span class="linenos">1174</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1175"><a href="#BigQuery-1175"><span class="linenos">1175</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"SAFE_"</span><span class="p">)</span> -</span><span id="BigQuery-1176"><a href="#BigQuery-1176"><span class="linenos">1176</span></a> -</span><span id="BigQuery-1177"><a href="#BigQuery-1177"><span class="linenos">1177</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1178"><a href="#BigQuery-1178"><span class="linenos">1178</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery-1179"><a href="#BigQuery-1179"><span class="linenos">1179</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery-812"><a href="#BigQuery-812"><span class="linenos"> 812</span></a> <span class="bp">self</span><span 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="BigQuery-813"><a href="#BigQuery-813"><span class="linenos"> 813</span></a> +</span><span id="BigQuery-814"><a href="#BigQuery-814"><span class="linenos"> 814</span></a> <span class="k">return</span> <span class="n">expr</span> +</span><span id="BigQuery-815"><a href="#BigQuery-815"><span class="linenos"> 815</span></a> +</span><span id="BigQuery-816"><a href="#BigQuery-816"><span class="linenos"> 816</span></a> <span class="k">def</span> <span class="nf">_parse_features_at_time</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">:</span> +</span><span id="BigQuery-817"><a href="#BigQuery-817"><span class="linenos"> 817</span></a> <span class="n">expr</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="BigQuery-818"><a href="#BigQuery-818"><span class="linenos"> 818</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">,</span> +</span><span id="BigQuery-819"><a href="#BigQuery-819"><span class="linenos"> 819</span></a> <span class="n">this</span><span class="o">=</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">TABLE</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="BigQuery-820"><a href="#BigQuery-820"><span class="linenos"> 820</span></a> <span class="ow">or</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="BigQuery-821"><a href="#BigQuery-821"><span class="linenos"> 821</span></a> <span class="p">)</span> +</span><span id="BigQuery-822"><a href="#BigQuery-822"><span class="linenos"> 822</span></a> +</span><span id="BigQuery-823"><a href="#BigQuery-823"><span class="linenos"> 823</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">COMMA</span><span class="p">):</span> +</span><span id="BigQuery-824"><a href="#BigQuery-824"><span class="linenos"> 824</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> +</span><span id="BigQuery-825"><a href="#BigQuery-825"><span class="linenos"> 825</span></a> +</span><span id="BigQuery-826"><a href="#BigQuery-826"><span class="linenos"> 826</span></a> <span class="c1"># Get the LHS of the Kwarg and set the arg to that value, e.g</span> +</span><span id="BigQuery-827"><a href="#BigQuery-827"><span class="linenos"> 827</span></a> <span class="c1"># "num_rows => 1" sets the expr's `num_rows` arg</span> +</span><span id="BigQuery-828"><a href="#BigQuery-828"><span class="linenos"> 828</span></a> <span class="k">if</span> <span class="n">arg</span><span class="p">:</span> +</span><span id="BigQuery-829"><a href="#BigQuery-829"><span class="linenos"> 829</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="BigQuery-830"><a href="#BigQuery-830"><span class="linenos"> 830</span></a> +</span><span id="BigQuery-831"><a href="#BigQuery-831"><span class="linenos"> 831</span></a> <span class="k">return</span> <span class="n">expr</span> +</span><span id="BigQuery-832"><a href="#BigQuery-832"><span class="linenos"> 832</span></a> +</span><span id="BigQuery-833"><a href="#BigQuery-833"><span class="linenos"> 833</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="BigQuery-834"><a href="#BigQuery-834"><span class="linenos"> 834</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-835"><a href="#BigQuery-835"><span class="linenos"> 835</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-836"><a href="#BigQuery-836"><span class="linenos"> 836</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-837"><a href="#BigQuery-837"><span class="linenos"> 837</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-838"><a href="#BigQuery-838"><span class="linenos"> 838</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="BigQuery-839"><a href="#BigQuery-839"><span class="linenos"> 839</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-840"><a href="#BigQuery-840"><span class="linenos"> 840</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-841"><a href="#BigQuery-841"><span class="linenos"> 841</span></a> <span class="n">UNNEST_WITH_ORDINALITY</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-842"><a href="#BigQuery-842"><span class="linenos"> 842</span></a> <span class="n">COLLATE_IS_FUNC</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-843"><a href="#BigQuery-843"><span class="linenos"> 843</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-844"><a href="#BigQuery-844"><span class="linenos"> 844</span></a> <span class="n">SUPPORTS_TABLE_ALIAS_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-845"><a href="#BigQuery-845"><span class="linenos"> 845</span></a> <span class="n">UNPIVOT_ALIASES_ARE_IDENTIFIERS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-846"><a href="#BigQuery-846"><span class="linenos"> 846</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="BigQuery-847"><a href="#BigQuery-847"><span class="linenos"> 847</span></a> <span class="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-848"><a href="#BigQuery-848"><span class="linenos"> 848</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-849"><a href="#BigQuery-849"><span class="linenos"> 849</span></a> <span class="n">JSON_PATH_SINGLE_QUOTE_ESCAPE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-850"><a href="#BigQuery-850"><span class="linenos"> 850</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-851"><a href="#BigQuery-851"><span class="linenos"> 851</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-852"><a href="#BigQuery-852"><span class="linenos"> 852</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> +</span><span id="BigQuery-853"><a href="#BigQuery-853"><span class="linenos"> 853</span></a> <span class="n">HEX_FUNC</span> <span class="o">=</span> <span class="s2">"TO_HEX"</span> +</span><span id="BigQuery-854"><a href="#BigQuery-854"><span class="linenos"> 854</span></a> <span class="n">WITH_PROPERTIES_PREFIX</span> <span class="o">=</span> <span class="s2">"OPTIONS"</span> +</span><span id="BigQuery-855"><a href="#BigQuery-855"><span class="linenos"> 855</span></a> <span class="n">SUPPORTS_EXPLODING_PROJECTIONS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-856"><a href="#BigQuery-856"><span class="linenos"> 856</span></a> <span class="n">EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-857"><a href="#BigQuery-857"><span class="linenos"> 857</span></a> <span class="n">SUPPORTS_UNIX_SECONDS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-858"><a href="#BigQuery-858"><span class="linenos"> 858</span></a> +</span><span id="BigQuery-859"><a href="#BigQuery-859"><span class="linenos"> 859</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-860"><a href="#BigQuery-860"><span class="linenos"> 860</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="BigQuery-861"><a href="#BigQuery-861"><span class="linenos"> 861</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> +</span><span id="BigQuery-862"><a href="#BigQuery-862"><span class="linenos"> 862</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> +</span><span id="BigQuery-863"><a href="#BigQuery-863"><span class="linenos"> 863</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> +</span><span id="BigQuery-864"><a href="#BigQuery-864"><span class="linenos"> 864</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> +</span><span id="BigQuery-865"><a href="#BigQuery-865"><span class="linenos"> 865</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">_array_contains_sql</span><span class="p">,</span> +</span><span id="BigQuery-866"><a href="#BigQuery-866"><span class="linenos"> 866</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">filter_array_using_unnest</span><span class="p">,</span> +</span><span id="BigQuery-867"><a href="#BigQuery-867"><span class="linenos"> 867</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_precision_parameterized_types</span><span class="p">]),</span> +</span><span id="BigQuery-868"><a href="#BigQuery-868"><span class="linenos"> 868</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> +</span><span id="BigQuery-869"><a href="#BigQuery-869"><span class="linenos"> 869</span></a> <span class="sa">f</span><span class="s2">"DEFAULT COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-870"><a href="#BigQuery-870"><span class="linenos"> 870</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> +</span><span id="BigQuery-871"><a href="#BigQuery-871"><span class="linenos"> 871</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-872"><a href="#BigQuery-872"><span class="linenos"> 872</span></a> <span class="p">),</span> +</span><span id="BigQuery-873"><a href="#BigQuery-873"><span class="linenos"> 873</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"COMMIT TRANSACTION"</span><span class="p">,</span> +</span><span id="BigQuery-874"><a href="#BigQuery-874"><span class="linenos"> 874</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COUNTIF"</span><span class="p">),</span> +</span><span id="BigQuery-875"><a href="#BigQuery-875"><span class="linenos"> 875</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> +</span><span id="BigQuery-876"><a href="#BigQuery-876"><span class="linenos"> 876</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_pushdown_cte_column_names</span><span class="p">]),</span> +</span><span id="BigQuery-877"><a href="#BigQuery-877"><span class="linenos"> 877</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery-878"><a href="#BigQuery-878"><span class="linenos"> 878</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery-879"><a href="#BigQuery-879"><span class="linenos"> 879</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">unit_to_var</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="BigQuery-880"><a href="#BigQuery-880"><span class="linenos"> 880</span></a> <span class="p">),</span> +</span><span id="BigQuery-881"><a href="#BigQuery-881"><span class="linenos"> 881</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">),</span> +</span><span id="BigQuery-882"><a href="#BigQuery-882"><span class="linenos"> 882</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> +</span><span id="BigQuery-883"><a href="#BigQuery-883"><span class="linenos"> 883</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery-884"><a href="#BigQuery-884"><span class="linenos"> 884</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery-885"><a href="#BigQuery-885"><span class="linenos"> 885</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery-886"><a href="#BigQuery-886"><span class="linenos"> 886</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery-887"><a href="#BigQuery-887"><span class="linenos"> 887</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)</span> +</span><span id="BigQuery-888"><a href="#BigQuery-888"><span class="linenos"> 888</span></a> <span class="p">),</span> +</span><span id="BigQuery-889"><a href="#BigQuery-889"><span class="linenos"> 889</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromTimeZone</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery-890"><a href="#BigQuery-890"><span class="linenos"> 890</span></a> <span class="s2">"DATETIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)),</span> <span class="s2">"'UTC'"</span> +</span><span id="BigQuery-891"><a href="#BigQuery-891"><span class="linenos"> 891</span></a> <span class="p">),</span> +</span><span id="BigQuery-892"><a href="#BigQuery-892"><span class="linenos"> 892</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GENERATE_ARRAY"</span><span class="p">),</span> +</span><span id="BigQuery-893"><a href="#BigQuery-893"><span class="linenos"> 893</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> +</span><span id="BigQuery-894"><a href="#BigQuery-894"><span class="linenos"> 894</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> +</span><span id="BigQuery-895"><a href="#BigQuery-895"><span class="linenos"> 895</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(</span><span class="n">false_value</span><span class="o">=</span><span class="s2">"NULL"</span><span class="p">),</span> +</span><span id="BigQuery-896"><a href="#BigQuery-896"><span class="linenos"> 896</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="BigQuery-897"><a href="#BigQuery-897"><span class="linenos"> 897</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> +</span><span id="BigQuery-898"><a href="#BigQuery-898"><span class="linenos"> 898</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Int64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"INT64"</span><span class="p">),</span> +</span><span id="BigQuery-899"><a href="#BigQuery-899"><span class="linenos"> 899</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> +</span><span id="BigQuery-900"><a href="#BigQuery-900"><span class="linenos"> 900</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractArray</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> +</span><span id="BigQuery-901"><a href="#BigQuery-901"><span class="linenos"> 901</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> +</span><span id="BigQuery-902"><a href="#BigQuery-902"><span class="linenos"> 902</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_JSON_STRING"</span><span class="p">),</span> +</span><span id="BigQuery-903"><a href="#BigQuery-903"><span class="linenos"> 903</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">_levenshtein_sql</span><span class="p">,</span> +</span><span id="BigQuery-904"><a href="#BigQuery-904"><span class="linenos"> 904</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="BigQuery-905"><a href="#BigQuery-905"><span class="linenos"> 905</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> +</span><span id="BigQuery-906"><a href="#BigQuery-906"><span class="linenos"> 906</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">),</span> +</span><span id="BigQuery-907"><a href="#BigQuery-907"><span class="linenos"> 907</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="BigQuery-908"><a href="#BigQuery-908"><span class="linenos"> 908</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="BigQuery-909"><a href="#BigQuery-909"><span class="linenos"> 909</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery-910"><a href="#BigQuery-910"><span class="linenos"> 910</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> +</span><span id="BigQuery-911"><a href="#BigQuery-911"><span class="linenos"> 911</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="BigQuery-912"><a href="#BigQuery-912"><span class="linenos"> 912</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="BigQuery-913"><a href="#BigQuery-913"><span class="linenos"> 913</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">),</span> +</span><span id="BigQuery-914"><a href="#BigQuery-914"><span class="linenos"> 914</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"occurrence"</span><span class="p">),</span> +</span><span id="BigQuery-915"><a href="#BigQuery-915"><span class="linenos"> 915</span></a> <span class="p">),</span> +</span><span id="BigQuery-916"><a href="#BigQuery-916"><span class="linenos"> 916</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtractAll</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery-917"><a href="#BigQuery-917"><span class="linenos"> 917</span></a> <span class="s2">"REGEXP_EXTRACT_ALL"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span> +</span><span id="BigQuery-918"><a href="#BigQuery-918"><span class="linenos"> 918</span></a> <span class="p">),</span> +</span><span id="BigQuery-919"><a href="#BigQuery-919"><span class="linenos"> 919</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="n">regexp_replace_sql</span><span class="p">,</span> +</span><span id="BigQuery-920"><a href="#BigQuery-920"><span class="linenos"> 920</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_CONTAINS"</span><span class="p">),</span> +</span><span id="BigQuery-921"><a href="#BigQuery-921"><span class="linenos"> 921</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> +</span><span id="BigQuery-922"><a href="#BigQuery-922"><span class="linenos"> 922</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"ROLLBACK TRANSACTION"</span><span class="p">,</span> +</span><span id="BigQuery-923"><a href="#BigQuery-923"><span class="linenos"> 923</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="BigQuery-924"><a href="#BigQuery-924"><span class="linenos"> 924</span></a> <span class="p">[</span> +</span><span id="BigQuery-925"><a href="#BigQuery-925"><span class="linenos"> 925</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(),</span> +</span><span id="BigQuery-926"><a href="#BigQuery-926"><span class="linenos"> 926</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> +</span><span id="BigQuery-927"><a href="#BigQuery-927"><span class="linenos"> 927</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="BigQuery-928"><a href="#BigQuery-928"><span class="linenos"> 928</span></a> <span class="n">_alias_ordered_group</span><span class="p">,</span> +</span><span id="BigQuery-929"><a href="#BigQuery-929"><span class="linenos"> 929</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">,</span> +</span><span id="BigQuery-930"><a href="#BigQuery-930"><span class="linenos"> 930</span></a> <span class="p">]</span> +</span><span id="BigQuery-931"><a href="#BigQuery-931"><span class="linenos"> 931</span></a> <span class="p">),</span> +</span><span id="BigQuery-932"><a href="#BigQuery-932"><span class="linenos"> 932</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SHA1"</span><span class="p">),</span> +</span><span id="BigQuery-933"><a href="#BigQuery-933"><span class="linenos"> 933</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA2</span><span class="p">:</span> <span class="n">sha256_sql</span><span class="p">,</span> +</span><span id="BigQuery-934"><a href="#BigQuery-934"><span class="linenos"> 934</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> +</span><span id="BigQuery-935"><a href="#BigQuery-935"><span class="linenos"> 935</span></a> <span class="s2">"DETERMINISTIC"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span> +</span><span id="BigQuery-936"><a href="#BigQuery-936"><span class="linenos"> 936</span></a> <span class="p">),</span> +</span><span id="BigQuery-937"><a href="#BigQuery-937"><span class="linenos"> 937</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">String</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING"</span><span class="p">),</span> +</span><span id="BigQuery-938"><a href="#BigQuery-938"><span class="linenos"> 938</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> +</span><span id="BigQuery-939"><a href="#BigQuery-939"><span class="linenos"> 939</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> +</span><span id="BigQuery-940"><a href="#BigQuery-940"><span class="linenos"> 940</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> +</span><span id="BigQuery-941"><a href="#BigQuery-941"><span class="linenos"> 941</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery-942"><a href="#BigQuery-942"><span class="linenos"> 942</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> +</span><span id="BigQuery-943"><a href="#BigQuery-943"><span class="linenos"> 943</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> +</span><span id="BigQuery-944"><a href="#BigQuery-944"><span class="linenos"> 944</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery-945"><a href="#BigQuery-945"><span class="linenos"> 945</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery-946"><a href="#BigQuery-946"><span class="linenos"> 946</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP_DIFF"</span><span class="p">),</span> +</span><span id="BigQuery-947"><a href="#BigQuery-947"><span class="linenos"> 947</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery-948"><a href="#BigQuery-948"><span class="linenos"> 948</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="BigQuery-949"><a href="#BigQuery-949"><span class="linenos"> 949</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">,</span> +</span><span id="BigQuery-950"><a href="#BigQuery-950"><span class="linenos"> 950</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="BigQuery-951"><a href="#BigQuery-951"><span class="linenos"> 951</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">_ts_or_ds_diff_sql</span><span class="p">,</span> +</span><span id="BigQuery-952"><a href="#BigQuery-952"><span class="linenos"> 952</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> +</span><span id="BigQuery-953"><a href="#BigQuery-953"><span class="linenos"> 953</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> +</span><span id="BigQuery-954"><a href="#BigQuery-954"><span class="linenos"> 954</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">),</span> +</span><span id="BigQuery-955"><a href="#BigQuery-955"><span class="linenos"> 955</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> +</span><span id="BigQuery-956"><a href="#BigQuery-956"><span class="linenos"> 956</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_DATE"</span><span class="p">),</span> +</span><span id="BigQuery-957"><a href="#BigQuery-957"><span class="linenos"> 957</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> +</span><span id="BigQuery-958"><a href="#BigQuery-958"><span class="linenos"> 958</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uuid</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"GENERATE_UUID()"</span><span class="p">,</span> +</span><span id="BigQuery-959"><a href="#BigQuery-959"><span class="linenos"> 959</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> +</span><span id="BigQuery-960"><a href="#BigQuery-960"><span class="linenos"> 960</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> +</span><span id="BigQuery-961"><a href="#BigQuery-961"><span class="linenos"> 961</span></a> <span class="p">}</span> +</span><span id="BigQuery-962"><a href="#BigQuery-962"><span class="linenos"> 962</span></a> +</span><span id="BigQuery-963"><a href="#BigQuery-963"><span class="linenos"> 963</span></a> <span class="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-964"><a href="#BigQuery-964"><span class="linenos"> 964</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> +</span><span id="BigQuery-965"><a href="#BigQuery-965"><span class="linenos"> 965</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> +</span><span id="BigQuery-966"><a href="#BigQuery-966"><span class="linenos"> 966</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> +</span><span id="BigQuery-967"><a href="#BigQuery-967"><span class="linenos"> 967</span></a> <span class="p">}</span> +</span><span id="BigQuery-968"><a href="#BigQuery-968"><span class="linenos"> 968</span></a> +</span><span id="BigQuery-969"><a href="#BigQuery-969"><span class="linenos"> 969</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-970"><a href="#BigQuery-970"><span class="linenos"> 970</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="BigQuery-971"><a href="#BigQuery-971"><span class="linenos"> 971</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> +</span><span id="BigQuery-972"><a href="#BigQuery-972"><span class="linenos"> 972</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery-973"><a href="#BigQuery-973"><span class="linenos"> 973</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery-974"><a href="#BigQuery-974"><span class="linenos"> 974</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> +</span><span id="BigQuery-975"><a href="#BigQuery-975"><span class="linenos"> 975</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-976"><a href="#BigQuery-976"><span class="linenos"> 976</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">:</span> <span class="s2">"NUMERIC"</span><span class="p">,</span> +</span><span id="BigQuery-977"><a href="#BigQuery-977"><span class="linenos"> 977</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="BigQuery-978"><a href="#BigQuery-978"><span class="linenos"> 978</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="BigQuery-979"><a href="#BigQuery-979"><span class="linenos"> 979</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery-980"><a href="#BigQuery-980"><span class="linenos"> 980</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-981"><a href="#BigQuery-981"><span class="linenos"> 981</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-982"><a href="#BigQuery-982"><span class="linenos"> 982</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery-983"><a href="#BigQuery-983"><span class="linenos"> 983</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-984"><a href="#BigQuery-984"><span class="linenos"> 984</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> +</span><span id="BigQuery-985"><a href="#BigQuery-985"><span class="linenos"> 985</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="BigQuery-986"><a href="#BigQuery-986"><span class="linenos"> 986</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="BigQuery-987"><a href="#BigQuery-987"><span class="linenos"> 987</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery-988"><a href="#BigQuery-988"><span class="linenos"> 988</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery-989"><a href="#BigQuery-989"><span class="linenos"> 989</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UUID</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-990"><a href="#BigQuery-990"><span class="linenos"> 990</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery-991"><a href="#BigQuery-991"><span class="linenos"> 991</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-992"><a href="#BigQuery-992"><span class="linenos"> 992</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> +</span><span id="BigQuery-993"><a href="#BigQuery-993"><span class="linenos"> 993</span></a> <span class="p">}</span> +</span><span id="BigQuery-994"><a href="#BigQuery-994"><span class="linenos"> 994</span></a> +</span><span id="BigQuery-995"><a href="#BigQuery-995"><span class="linenos"> 995</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-996"><a href="#BigQuery-996"><span class="linenos"> 996</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="BigQuery-997"><a href="#BigQuery-997"><span class="linenos"> 997</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="BigQuery-998"><a href="#BigQuery-998"><span class="linenos"> 998</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="BigQuery-999"><a href="#BigQuery-999"><span class="linenos"> 999</span></a> <span class="p">}</span> +</span><span id="BigQuery-1000"><a href="#BigQuery-1000"><span class="linenos">1000</span></a> +</span><span id="BigQuery-1001"><a href="#BigQuery-1001"><span class="linenos">1001</span></a> <span class="c1"># WINDOW comes after QUALIFY</span> +</span><span id="BigQuery-1002"><a href="#BigQuery-1002"><span class="linenos">1002</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#window_clause</span> +</span><span id="BigQuery-1003"><a href="#BigQuery-1003"><span class="linenos">1003</span></a> <span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-1004"><a href="#BigQuery-1004"><span class="linenos">1004</span></a> <span class="s2">"qualify"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"qualify"</span><span class="p">],</span> +</span><span id="BigQuery-1005"><a href="#BigQuery-1005"><span class="linenos">1005</span></a> <span class="s2">"windows"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"windows"</span><span class="p">],</span> +</span><span id="BigQuery-1006"><a href="#BigQuery-1006"><span class="linenos">1006</span></a> <span class="p">}</span> +</span><span id="BigQuery-1007"><a href="#BigQuery-1007"><span class="linenos">1007</span></a> +</span><span id="BigQuery-1008"><a href="#BigQuery-1008"><span class="linenos">1008</span></a> <span class="c1"># from: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords</span> +</span><span id="BigQuery-1009"><a href="#BigQuery-1009"><span class="linenos">1009</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-1010"><a href="#BigQuery-1010"><span class="linenos">1010</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="BigQuery-1011"><a href="#BigQuery-1011"><span class="linenos">1011</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="BigQuery-1012"><a href="#BigQuery-1012"><span class="linenos">1012</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="BigQuery-1013"><a href="#BigQuery-1013"><span class="linenos">1013</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="BigQuery-1014"><a href="#BigQuery-1014"><span class="linenos">1014</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="BigQuery-1015"><a href="#BigQuery-1015"><span class="linenos">1015</span></a> <span class="s2">"asc"</span><span class="p">,</span> +</span><span id="BigQuery-1016"><a href="#BigQuery-1016"><span class="linenos">1016</span></a> <span class="s2">"assert_rows_modified"</span><span class="p">,</span> +</span><span id="BigQuery-1017"><a href="#BigQuery-1017"><span class="linenos">1017</span></a> <span class="s2">"at"</span><span class="p">,</span> +</span><span id="BigQuery-1018"><a href="#BigQuery-1018"><span class="linenos">1018</span></a> <span class="s2">"between"</span><span class="p">,</span> +</span><span id="BigQuery-1019"><a href="#BigQuery-1019"><span class="linenos">1019</span></a> <span class="s2">"by"</span><span class="p">,</span> +</span><span id="BigQuery-1020"><a href="#BigQuery-1020"><span class="linenos">1020</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="BigQuery-1021"><a href="#BigQuery-1021"><span class="linenos">1021</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="BigQuery-1022"><a href="#BigQuery-1022"><span class="linenos">1022</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="BigQuery-1023"><a href="#BigQuery-1023"><span class="linenos">1023</span></a> <span class="s2">"contains"</span><span class="p">,</span> +</span><span id="BigQuery-1024"><a href="#BigQuery-1024"><span class="linenos">1024</span></a> <span class="s2">"create"</span><span class="p">,</span> +</span><span id="BigQuery-1025"><a href="#BigQuery-1025"><span class="linenos">1025</span></a> <span class="s2">"cross"</span><span class="p">,</span> +</span><span id="BigQuery-1026"><a href="#BigQuery-1026"><span class="linenos">1026</span></a> <span class="s2">"cube"</span><span class="p">,</span> +</span><span id="BigQuery-1027"><a href="#BigQuery-1027"><span class="linenos">1027</span></a> <span class="s2">"current"</span><span class="p">,</span> +</span><span id="BigQuery-1028"><a href="#BigQuery-1028"><span class="linenos">1028</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="BigQuery-1029"><a href="#BigQuery-1029"><span class="linenos">1029</span></a> <span class="s2">"define"</span><span class="p">,</span> +</span><span id="BigQuery-1030"><a href="#BigQuery-1030"><span class="linenos">1030</span></a> <span class="s2">"desc"</span><span class="p">,</span> +</span><span id="BigQuery-1031"><a href="#BigQuery-1031"><span class="linenos">1031</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="BigQuery-1032"><a href="#BigQuery-1032"><span class="linenos">1032</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="BigQuery-1033"><a href="#BigQuery-1033"><span class="linenos">1033</span></a> <span class="s2">"end"</span><span class="p">,</span> +</span><span id="BigQuery-1034"><a href="#BigQuery-1034"><span class="linenos">1034</span></a> <span class="s2">"enum"</span><span class="p">,</span> +</span><span id="BigQuery-1035"><a href="#BigQuery-1035"><span class="linenos">1035</span></a> <span class="s2">"escape"</span><span class="p">,</span> +</span><span id="BigQuery-1036"><a href="#BigQuery-1036"><span class="linenos">1036</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="BigQuery-1037"><a href="#BigQuery-1037"><span class="linenos">1037</span></a> <span class="s2">"exclude"</span><span class="p">,</span> +</span><span id="BigQuery-1038"><a href="#BigQuery-1038"><span class="linenos">1038</span></a> <span class="s2">"exists"</span><span class="p">,</span> +</span><span id="BigQuery-1039"><a href="#BigQuery-1039"><span class="linenos">1039</span></a> <span class="s2">"extract"</span><span class="p">,</span> +</span><span id="BigQuery-1040"><a href="#BigQuery-1040"><span class="linenos">1040</span></a> <span class="s2">"false"</span><span class="p">,</span> +</span><span id="BigQuery-1041"><a href="#BigQuery-1041"><span class="linenos">1041</span></a> <span class="s2">"fetch"</span><span class="p">,</span> +</span><span id="BigQuery-1042"><a href="#BigQuery-1042"><span class="linenos">1042</span></a> <span class="s2">"following"</span><span class="p">,</span> +</span><span id="BigQuery-1043"><a href="#BigQuery-1043"><span class="linenos">1043</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="BigQuery-1044"><a href="#BigQuery-1044"><span class="linenos">1044</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="BigQuery-1045"><a href="#BigQuery-1045"><span class="linenos">1045</span></a> <span class="s2">"full"</span><span class="p">,</span> +</span><span id="BigQuery-1046"><a href="#BigQuery-1046"><span class="linenos">1046</span></a> <span class="s2">"group"</span><span class="p">,</span> +</span><span id="BigQuery-1047"><a href="#BigQuery-1047"><span class="linenos">1047</span></a> <span class="s2">"grouping"</span><span class="p">,</span> +</span><span id="BigQuery-1048"><a href="#BigQuery-1048"><span class="linenos">1048</span></a> <span class="s2">"groups"</span><span class="p">,</span> +</span><span id="BigQuery-1049"><a href="#BigQuery-1049"><span class="linenos">1049</span></a> <span class="s2">"hash"</span><span class="p">,</span> +</span><span id="BigQuery-1050"><a href="#BigQuery-1050"><span class="linenos">1050</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="BigQuery-1051"><a href="#BigQuery-1051"><span class="linenos">1051</span></a> <span class="s2">"if"</span><span class="p">,</span> +</span><span id="BigQuery-1052"><a href="#BigQuery-1052"><span class="linenos">1052</span></a> <span class="s2">"ignore"</span><span class="p">,</span> +</span><span id="BigQuery-1053"><a href="#BigQuery-1053"><span class="linenos">1053</span></a> <span class="s2">"in"</span><span class="p">,</span> +</span><span id="BigQuery-1054"><a href="#BigQuery-1054"><span class="linenos">1054</span></a> <span class="s2">"inner"</span><span class="p">,</span> +</span><span id="BigQuery-1055"><a href="#BigQuery-1055"><span class="linenos">1055</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="BigQuery-1056"><a href="#BigQuery-1056"><span class="linenos">1056</span></a> <span class="s2">"interval"</span><span class="p">,</span> +</span><span id="BigQuery-1057"><a href="#BigQuery-1057"><span class="linenos">1057</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="BigQuery-1058"><a href="#BigQuery-1058"><span class="linenos">1058</span></a> <span class="s2">"is"</span><span class="p">,</span> +</span><span id="BigQuery-1059"><a href="#BigQuery-1059"><span class="linenos">1059</span></a> <span class="s2">"join"</span><span class="p">,</span> +</span><span id="BigQuery-1060"><a href="#BigQuery-1060"><span class="linenos">1060</span></a> <span class="s2">"lateral"</span><span class="p">,</span> +</span><span id="BigQuery-1061"><a href="#BigQuery-1061"><span class="linenos">1061</span></a> <span class="s2">"left"</span><span class="p">,</span> +</span><span id="BigQuery-1062"><a href="#BigQuery-1062"><span class="linenos">1062</span></a> <span class="s2">"like"</span><span class="p">,</span> +</span><span id="BigQuery-1063"><a href="#BigQuery-1063"><span class="linenos">1063</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="BigQuery-1064"><a href="#BigQuery-1064"><span class="linenos">1064</span></a> <span class="s2">"lookup"</span><span class="p">,</span> +</span><span id="BigQuery-1065"><a href="#BigQuery-1065"><span class="linenos">1065</span></a> <span class="s2">"merge"</span><span class="p">,</span> +</span><span id="BigQuery-1066"><a href="#BigQuery-1066"><span class="linenos">1066</span></a> <span class="s2">"natural"</span><span class="p">,</span> +</span><span id="BigQuery-1067"><a href="#BigQuery-1067"><span class="linenos">1067</span></a> <span class="s2">"new"</span><span class="p">,</span> +</span><span id="BigQuery-1068"><a href="#BigQuery-1068"><span class="linenos">1068</span></a> <span class="s2">"no"</span><span class="p">,</span> +</span><span id="BigQuery-1069"><a href="#BigQuery-1069"><span class="linenos">1069</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="BigQuery-1070"><a href="#BigQuery-1070"><span class="linenos">1070</span></a> <span class="s2">"null"</span><span class="p">,</span> +</span><span id="BigQuery-1071"><a href="#BigQuery-1071"><span class="linenos">1071</span></a> <span class="s2">"nulls"</span><span class="p">,</span> +</span><span id="BigQuery-1072"><a href="#BigQuery-1072"><span class="linenos">1072</span></a> <span class="s2">"of"</span><span class="p">,</span> +</span><span id="BigQuery-1073"><a href="#BigQuery-1073"><span class="linenos">1073</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="BigQuery-1074"><a href="#BigQuery-1074"><span class="linenos">1074</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="BigQuery-1075"><a href="#BigQuery-1075"><span class="linenos">1075</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="BigQuery-1076"><a href="#BigQuery-1076"><span class="linenos">1076</span></a> <span class="s2">"outer"</span><span class="p">,</span> +</span><span id="BigQuery-1077"><a href="#BigQuery-1077"><span class="linenos">1077</span></a> <span class="s2">"over"</span><span class="p">,</span> +</span><span id="BigQuery-1078"><a href="#BigQuery-1078"><span class="linenos">1078</span></a> <span class="s2">"partition"</span><span class="p">,</span> +</span><span id="BigQuery-1079"><a href="#BigQuery-1079"><span class="linenos">1079</span></a> <span class="s2">"preceding"</span><span class="p">,</span> +</span><span id="BigQuery-1080"><a href="#BigQuery-1080"><span class="linenos">1080</span></a> <span class="s2">"proto"</span><span class="p">,</span> +</span><span id="BigQuery-1081"><a href="#BigQuery-1081"><span class="linenos">1081</span></a> <span class="s2">"qualify"</span><span class="p">,</span> +</span><span id="BigQuery-1082"><a href="#BigQuery-1082"><span class="linenos">1082</span></a> <span class="s2">"range"</span><span class="p">,</span> +</span><span id="BigQuery-1083"><a href="#BigQuery-1083"><span class="linenos">1083</span></a> <span class="s2">"recursive"</span><span class="p">,</span> +</span><span id="BigQuery-1084"><a href="#BigQuery-1084"><span class="linenos">1084</span></a> <span class="s2">"respect"</span><span class="p">,</span> +</span><span id="BigQuery-1085"><a href="#BigQuery-1085"><span class="linenos">1085</span></a> <span class="s2">"right"</span><span class="p">,</span> +</span><span id="BigQuery-1086"><a href="#BigQuery-1086"><span class="linenos">1086</span></a> <span class="s2">"rollup"</span><span class="p">,</span> +</span><span id="BigQuery-1087"><a href="#BigQuery-1087"><span class="linenos">1087</span></a> <span class="s2">"rows"</span><span class="p">,</span> +</span><span id="BigQuery-1088"><a href="#BigQuery-1088"><span class="linenos">1088</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="BigQuery-1089"><a href="#BigQuery-1089"><span class="linenos">1089</span></a> <span class="s2">"set"</span><span class="p">,</span> +</span><span id="BigQuery-1090"><a href="#BigQuery-1090"><span class="linenos">1090</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="BigQuery-1091"><a href="#BigQuery-1091"><span class="linenos">1091</span></a> <span class="s2">"struct"</span><span class="p">,</span> +</span><span id="BigQuery-1092"><a href="#BigQuery-1092"><span class="linenos">1092</span></a> <span class="s2">"tablesample"</span><span class="p">,</span> +</span><span id="BigQuery-1093"><a href="#BigQuery-1093"><span class="linenos">1093</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="BigQuery-1094"><a href="#BigQuery-1094"><span class="linenos">1094</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="BigQuery-1095"><a href="#BigQuery-1095"><span class="linenos">1095</span></a> <span class="s2">"treat"</span><span class="p">,</span> +</span><span id="BigQuery-1096"><a href="#BigQuery-1096"><span class="linenos">1096</span></a> <span class="s2">"true"</span><span class="p">,</span> +</span><span id="BigQuery-1097"><a href="#BigQuery-1097"><span class="linenos">1097</span></a> <span class="s2">"unbounded"</span><span class="p">,</span> +</span><span id="BigQuery-1098"><a href="#BigQuery-1098"><span class="linenos">1098</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="BigQuery-1099"><a href="#BigQuery-1099"><span class="linenos">1099</span></a> <span class="s2">"unnest"</span><span class="p">,</span> +</span><span id="BigQuery-1100"><a href="#BigQuery-1100"><span class="linenos">1100</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="BigQuery-1101"><a href="#BigQuery-1101"><span class="linenos">1101</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="BigQuery-1102"><a href="#BigQuery-1102"><span class="linenos">1102</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="BigQuery-1103"><a href="#BigQuery-1103"><span class="linenos">1103</span></a> <span class="s2">"window"</span><span class="p">,</span> +</span><span id="BigQuery-1104"><a href="#BigQuery-1104"><span class="linenos">1104</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="BigQuery-1105"><a href="#BigQuery-1105"><span class="linenos">1105</span></a> <span class="s2">"within"</span><span class="p">,</span> +</span><span id="BigQuery-1106"><a href="#BigQuery-1106"><span class="linenos">1106</span></a> <span class="p">}</span> +</span><span id="BigQuery-1107"><a href="#BigQuery-1107"><span class="linenos">1107</span></a> +</span><span id="BigQuery-1108"><a href="#BigQuery-1108"><span class="linenos">1108</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1109"><a href="#BigQuery-1109"><span class="linenos">1109</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery-1110"><a href="#BigQuery-1110"><span class="linenos">1110</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="BigQuery-1111"><a href="#BigQuery-1111"><span class="linenos">1111</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery-1112"><a href="#BigQuery-1112"><span class="linenos">1112</span></a> <span class="s2">"MOD"</span><span class="p">,</span> +</span><span id="BigQuery-1113"><a href="#BigQuery-1113"><span class="linenos">1113</span></a> <span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <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">Paren</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> +</span><span id="BigQuery-1114"><a href="#BigQuery-1114"><span class="linenos">1114</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</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="k">else</span> <span class="n">expr</span><span class="p">,</span> +</span><span id="BigQuery-1115"><a href="#BigQuery-1115"><span class="linenos">1115</span></a> <span class="p">)</span> +</span><span id="BigQuery-1116"><a href="#BigQuery-1116"><span class="linenos">1116</span></a> +</span><span id="BigQuery-1117"><a href="#BigQuery-1117"><span class="linenos">1117</span></a> <span class="k">def</span> <span class="nf">column_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1118"><a href="#BigQuery-1118"><span class="linenos">1118</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_column"</span><span class="p">):</span> +</span><span id="BigQuery-1119"><a href="#BigQuery-1119"><span class="linenos">1119</span></a> <span class="c1"># If a column reference is of the form `dataset.table`.name, we need</span> +</span><span id="BigQuery-1120"><a href="#BigQuery-1120"><span class="linenos">1120</span></a> <span class="c1"># to preserve the quoted table path, otherwise the reference breaks</span> +</span><span id="BigQuery-1121"><a href="#BigQuery-1121"><span class="linenos">1121</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> +</span><span id="BigQuery-1122"><a href="#BigQuery-1122"><span class="linenos">1122</span></a> <span class="n">table_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</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="BigQuery-1123"><a href="#BigQuery-1123"><span class="linenos">1123</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_path</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-1124"><a href="#BigQuery-1124"><span class="linenos">1124</span></a> +</span><span id="BigQuery-1125"><a href="#BigQuery-1125"><span class="linenos">1125</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">column_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="BigQuery-1126"><a href="#BigQuery-1126"><span class="linenos">1126</span></a> +</span><span id="BigQuery-1127"><a href="#BigQuery-1127"><span class="linenos">1127</span></a> <span class="k">def</span> <span class="nf">table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1128"><a href="#BigQuery-1128"><span class="linenos">1128</span></a> <span class="c1"># Depending on the context, `x.y` may not resolve to the same data source as `x`.`y`, so</span> +</span><span id="BigQuery-1129"><a href="#BigQuery-1129"><span class="linenos">1129</span></a> <span class="c1"># we need to make sure the correct quoting is used in each case.</span> +</span><span id="BigQuery-1130"><a href="#BigQuery-1130"><span class="linenos">1130</span></a> <span class="c1">#</span> +</span><span id="BigQuery-1131"><a href="#BigQuery-1131"><span class="linenos">1131</span></a> <span class="c1"># For example, if there is a CTE x that clashes with a schema name, then the former will</span> +</span><span id="BigQuery-1132"><a href="#BigQuery-1132"><span class="linenos">1132</span></a> <span class="c1"># return the table y in that schema, whereas the latter will return the CTE's y column:</span> +</span><span id="BigQuery-1133"><a href="#BigQuery-1133"><span class="linenos">1133</span></a> <span class="c1">#</span> +</span><span id="BigQuery-1134"><a href="#BigQuery-1134"><span class="linenos">1134</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x.y` -> cross join</span> +</span><span id="BigQuery-1135"><a href="#BigQuery-1135"><span class="linenos">1135</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x`.`y` -> implicit unnest</span> +</span><span id="BigQuery-1136"><a href="#BigQuery-1136"><span class="linenos">1136</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_table"</span><span class="p">):</span> +</span><span id="BigQuery-1137"><a href="#BigQuery-1137"><span class="linenos">1137</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">)</span> +</span><span id="BigQuery-1138"><a href="#BigQuery-1138"><span class="linenos">1138</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="BigQuery-1139"><a href="#BigQuery-1139"><span class="linenos">1139</span></a> +</span><span id="BigQuery-1140"><a href="#BigQuery-1140"><span class="linenos">1140</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">table_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="BigQuery-1141"><a href="#BigQuery-1141"><span class="linenos">1141</span></a> +</span><span id="BigQuery-1142"><a href="#BigQuery-1142"><span class="linenos">1142</span></a> <span class="k">def</span> <span class="nf">timetostr_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1143"><a href="#BigQuery-1143"><span class="linenos">1143</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery-1144"><a href="#BigQuery-1144"><span class="linenos">1144</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">TsOrDsToDatetime</span><span class="p">):</span> +</span><span id="BigQuery-1145"><a href="#BigQuery-1145"><span class="linenos">1145</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATETIME"</span> +</span><span id="BigQuery-1146"><a href="#BigQuery-1146"><span class="linenos">1146</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">TsOrDsToTimestamp</span><span class="p">):</span> +</span><span id="BigQuery-1147"><a href="#BigQuery-1147"><span class="linenos">1147</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_TIMESTAMP"</span> +</span><span id="BigQuery-1148"><a href="#BigQuery-1148"><span class="linenos">1148</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="BigQuery-1149"><a href="#BigQuery-1149"><span class="linenos">1149</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATE"</span> +</span><span id="BigQuery-1150"><a href="#BigQuery-1150"><span class="linenos">1150</span></a> +</span><span id="BigQuery-1151"><a href="#BigQuery-1151"><span class="linenos">1151</span></a> <span class="n">time_expr</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="BigQuery-1152"><a href="#BigQuery-1152"><span class="linenos">1152</span></a> <span class="n">this</span> +</span><span id="BigQuery-1153"><a href="#BigQuery-1153"><span class="linenos">1153</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="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">))</span> +</span><span id="BigQuery-1154"><a href="#BigQuery-1154"><span class="linenos">1154</span></a> <span class="k">else</span> <span class="n">expression</span> +</span><span id="BigQuery-1155"><a href="#BigQuery-1155"><span class="linenos">1155</span></a> <span class="p">)</span> +</span><span id="BigQuery-1156"><a href="#BigQuery-1156"><span class="linenos">1156</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">time_expr</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="BigQuery-1157"><a href="#BigQuery-1157"><span class="linenos">1157</span></a> +</span><span id="BigQuery-1158"><a href="#BigQuery-1158"><span class="linenos">1158</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1159"><a href="#BigQuery-1159"><span class="linenos">1159</span></a> <span class="c1"># Operands of = cannot be NULL in BigQuery</span> +</span><span id="BigQuery-1160"><a href="#BigQuery-1160"><span class="linenos">1160</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">right</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">):</span> +</span><span id="BigQuery-1161"><a href="#BigQuery-1161"><span class="linenos">1161</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="BigQuery-1162"><a href="#BigQuery-1162"><span class="linenos">1162</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> +</span><span id="BigQuery-1163"><a href="#BigQuery-1163"><span class="linenos">1163</span></a> +</span><span id="BigQuery-1164"><a href="#BigQuery-1164"><span class="linenos">1164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> +</span><span id="BigQuery-1165"><a href="#BigQuery-1165"><span class="linenos">1165</span></a> +</span><span id="BigQuery-1166"><a href="#BigQuery-1166"><span class="linenos">1166</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1167"><a href="#BigQuery-1167"><span class="linenos">1167</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> +</span><span id="BigQuery-1168"><a href="#BigQuery-1168"><span class="linenos">1168</span></a> +</span><span id="BigQuery-1169"><a href="#BigQuery-1169"><span class="linenos">1169</span></a> <span class="c1"># BigQuery allows CAST(.. AS {STRING|TIMESTAMP} [FORMAT <fmt> [AT TIME ZONE <tz>]]).</span> +</span><span id="BigQuery-1170"><a href="#BigQuery-1170"><span class="linenos">1170</span></a> <span class="c1"># Only the TIMESTAMP one should use the below conversion, when AT TIME ZONE is included.</span> +</span><span id="BigQuery-1171"><a href="#BigQuery-1171"><span class="linenos">1171</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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> +</span><span id="BigQuery-1172"><a href="#BigQuery-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery-1173"><a href="#BigQuery-1173"><span class="linenos">1173</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">))</span> +</span><span id="BigQuery-1174"><a href="#BigQuery-1174"><span class="linenos">1174</span></a> <span class="p">)</span> +</span><span id="BigQuery-1175"><a href="#BigQuery-1175"><span class="linenos">1175</span></a> +</span><span id="BigQuery-1176"><a href="#BigQuery-1176"><span class="linenos">1176</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">attimezone_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="BigQuery-1177"><a href="#BigQuery-1177"><span class="linenos">1177</span></a> +</span><span id="BigQuery-1178"><a href="#BigQuery-1178"><span class="linenos">1178</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1179"><a href="#BigQuery-1179"><span class="linenos">1179</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"SAFE_"</span><span class="p">)</span> </span><span id="BigQuery-1180"><a href="#BigQuery-1180"><span class="linenos">1180</span></a> -</span><span id="BigQuery-1181"><a href="#BigQuery-1181"><span class="linenos">1181</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="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">):</span> -</span><span id="BigQuery-1182"><a href="#BigQuery-1182"><span class="linenos">1182</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="BigQuery-1183"><a href="#BigQuery-1183"><span class="linenos">1183</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="BigQuery-1184"><a href="#BigQuery-1184"><span class="linenos">1184</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> -</span><span id="BigQuery-1185"><a href="#BigQuery-1185"><span class="linenos">1185</span></a> -</span><span id="BigQuery-1186"><a href="#BigQuery-1186"><span class="linenos">1186</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> -</span><span id="BigQuery-1187"><a href="#BigQuery-1187"><span class="linenos">1187</span></a> -</span><span id="BigQuery-1188"><a href="#BigQuery-1188"><span class="linenos">1188</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">and</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</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">TEXT_TYPES</span><span class="p">:</span> -</span><span id="BigQuery-1189"><a href="#BigQuery-1189"><span class="linenos">1189</span></a> <span class="c1"># BQ doesn't support bracket syntax with string values for structs</span> -</span><span id="BigQuery-1190"><a href="#BigQuery-1190"><span class="linenos">1190</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-1181"><a href="#BigQuery-1181"><span class="linenos">1181</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1182"><a href="#BigQuery-1182"><span class="linenos">1182</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery-1183"><a href="#BigQuery-1183"><span class="linenos">1183</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery-1184"><a href="#BigQuery-1184"><span class="linenos">1184</span></a> +</span><span id="BigQuery-1185"><a href="#BigQuery-1185"><span class="linenos">1185</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="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">):</span> +</span><span id="BigQuery-1186"><a href="#BigQuery-1186"><span class="linenos">1186</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="BigQuery-1187"><a href="#BigQuery-1187"><span class="linenos">1187</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="BigQuery-1188"><a href="#BigQuery-1188"><span class="linenos">1188</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="BigQuery-1189"><a href="#BigQuery-1189"><span class="linenos">1189</span></a> +</span><span id="BigQuery-1190"><a href="#BigQuery-1190"><span class="linenos">1190</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> </span><span id="BigQuery-1191"><a href="#BigQuery-1191"><span class="linenos">1191</span></a> -</span><span id="BigQuery-1192"><a href="#BigQuery-1192"><span class="linenos">1192</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="BigQuery-1193"><a href="#BigQuery-1193"><span class="linenos">1193</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> -</span><span id="BigQuery-1194"><a href="#BigQuery-1194"><span class="linenos">1194</span></a> -</span><span id="BigQuery-1195"><a href="#BigQuery-1195"><span class="linenos">1195</span></a> <span class="k">if</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="BigQuery-1196"><a href="#BigQuery-1196"><span class="linenos">1196</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OFFSET(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="BigQuery-1197"><a href="#BigQuery-1197"><span class="linenos">1197</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="BigQuery-1198"><a href="#BigQuery-1198"><span class="linenos">1198</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ORDINAL(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="BigQuery-1199"><a href="#BigQuery-1199"><span class="linenos">1199</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="BigQuery-1200"><a href="#BigQuery-1200"><span class="linenos">1200</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported array offset: </span><span class="si">{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="BigQuery-1201"><a href="#BigQuery-1201"><span class="linenos">1201</span></a> -</span><span id="BigQuery-1202"><a href="#BigQuery-1202"><span class="linenos">1202</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">):</span> -</span><span id="BigQuery-1203"><a href="#BigQuery-1203"><span class="linenos">1203</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"SAFE_</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery-1204"><a href="#BigQuery-1204"><span class="linenos">1204</span></a> -</span><span id="BigQuery-1205"><a href="#BigQuery-1205"><span class="linenos">1205</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> -</span><span id="BigQuery-1206"><a href="#BigQuery-1206"><span class="linenos">1206</span></a> -</span><span id="BigQuery-1207"><a href="#BigQuery-1207"><span class="linenos">1207</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1208"><a href="#BigQuery-1208"><span class="linenos">1208</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery-1209"><a href="#BigQuery-1209"><span class="linenos">1209</span></a> -</span><span id="BigQuery-1210"><a href="#BigQuery-1210"><span class="linenos">1210</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1211"><a href="#BigQuery-1211"><span class="linenos">1211</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> -</span><span id="BigQuery-1212"><a href="#BigQuery-1212"><span class="linenos">1212</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"SYSTEM_TIME"</span><span class="p">)</span> -</span><span id="BigQuery-1213"><a href="#BigQuery-1213"><span class="linenos">1213</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">version_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery-1214"><a href="#BigQuery-1214"><span class="linenos">1214</span></a> -</span><span id="BigQuery-1215"><a href="#BigQuery-1215"><span class="linenos">1215</span></a> <span class="k">def</span> <span class="nf">contains_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Contains</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-1216"><a href="#BigQuery-1216"><span class="linenos">1216</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery-1217"><a href="#BigQuery-1217"><span class="linenos">1217</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="BigQuery-1192"><a href="#BigQuery-1192"><span class="linenos">1192</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">and</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</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">TEXT_TYPES</span><span class="p">:</span> +</span><span id="BigQuery-1193"><a href="#BigQuery-1193"><span class="linenos">1193</span></a> <span class="c1"># BQ doesn't support bracket syntax with string values for structs</span> +</span><span id="BigQuery-1194"><a href="#BigQuery-1194"><span class="linenos">1194</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-1195"><a href="#BigQuery-1195"><span class="linenos">1195</span></a> +</span><span id="BigQuery-1196"><a href="#BigQuery-1196"><span class="linenos">1196</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="BigQuery-1197"><a href="#BigQuery-1197"><span class="linenos">1197</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> +</span><span id="BigQuery-1198"><a href="#BigQuery-1198"><span class="linenos">1198</span></a> +</span><span id="BigQuery-1199"><a href="#BigQuery-1199"><span class="linenos">1199</span></a> <span class="k">if</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="BigQuery-1200"><a href="#BigQuery-1200"><span class="linenos">1200</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OFFSET(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="BigQuery-1201"><a href="#BigQuery-1201"><span class="linenos">1201</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="BigQuery-1202"><a href="#BigQuery-1202"><span class="linenos">1202</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ORDINAL(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="BigQuery-1203"><a href="#BigQuery-1203"><span class="linenos">1203</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="BigQuery-1204"><a href="#BigQuery-1204"><span class="linenos">1204</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported array offset: </span><span class="si">{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="BigQuery-1205"><a href="#BigQuery-1205"><span class="linenos">1205</span></a> +</span><span id="BigQuery-1206"><a href="#BigQuery-1206"><span class="linenos">1206</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">):</span> +</span><span id="BigQuery-1207"><a href="#BigQuery-1207"><span class="linenos">1207</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"SAFE_</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-1208"><a href="#BigQuery-1208"><span class="linenos">1208</span></a> +</span><span id="BigQuery-1209"><a href="#BigQuery-1209"><span class="linenos">1209</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="BigQuery-1210"><a href="#BigQuery-1210"><span class="linenos">1210</span></a> +</span><span id="BigQuery-1211"><a href="#BigQuery-1211"><span class="linenos">1211</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1212"><a href="#BigQuery-1212"><span class="linenos">1212</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="BigQuery-1213"><a href="#BigQuery-1213"><span class="linenos">1213</span></a> +</span><span id="BigQuery-1214"><a href="#BigQuery-1214"><span class="linenos">1214</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1215"><a href="#BigQuery-1215"><span class="linenos">1215</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> +</span><span id="BigQuery-1216"><a href="#BigQuery-1216"><span class="linenos">1216</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"SYSTEM_TIME"</span><span class="p">)</span> +</span><span id="BigQuery-1217"><a href="#BigQuery-1217"><span class="linenos">1217</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">version_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="BigQuery-1218"><a href="#BigQuery-1218"><span class="linenos">1218</span></a> -</span><span id="BigQuery-1219"><a href="#BigQuery-1219"><span class="linenos">1219</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">Lower</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">):</span> -</span><span id="BigQuery-1220"><a href="#BigQuery-1220"><span class="linenos">1220</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="BigQuery-1221"><a href="#BigQuery-1221"><span class="linenos">1221</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery-1219"><a href="#BigQuery-1219"><span class="linenos">1219</span></a> <span class="k">def</span> <span class="nf">contains_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Contains</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-1220"><a href="#BigQuery-1220"><span class="linenos">1220</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery-1221"><a href="#BigQuery-1221"><span class="linenos">1221</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> </span><span id="BigQuery-1222"><a href="#BigQuery-1222"><span class="linenos">1222</span></a> -</span><span id="BigQuery-1223"><a href="#BigQuery-1223"><span class="linenos">1223</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONTAINS_SUBSTR"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> +</span><span id="BigQuery-1223"><a href="#BigQuery-1223"><span class="linenos">1223</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">Lower</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">):</span> +</span><span id="BigQuery-1224"><a href="#BigQuery-1224"><span class="linenos">1224</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="BigQuery-1225"><a href="#BigQuery-1225"><span class="linenos">1225</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery-1226"><a href="#BigQuery-1226"><span class="linenos">1226</span></a> +</span><span id="BigQuery-1227"><a href="#BigQuery-1227"><span class="linenos">1227</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONTAINS_SUBSTR"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> </span></pre></div> @@ -2828,7 +2839,7 @@ must be explicitly specified.</p> <div class="attr variable"> <span class="name">ANNOTATORS</span><span class="annotation">: Dict[Type[~E], Callable[[<a href="../optimizer/annotate_types.html#TypeAnnotator">sqlglot.optimizer.annotate_types.TypeAnnotator</a>, ~E], ~E]]</span> = <input id="BigQuery.ANNOTATORS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="BigQuery.ANNOTATORS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#Alias">sqlglot.expressions.Alias</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseNot">sqlglot.expressions.BitwiseNot</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Neg">sqlglot.expressions.Neg</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Not">sqlglot.expressions.Not</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Paren">sqlglot.expressions.Paren</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#PivotAlias">sqlglot.expressions.PivotAlias</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Unary">sqlglot.expressions.Unary</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Add">sqlglot.expressions.Add</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#And">sqlglot.expressions.And</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ArrayContainsAll">sqlglot.expressions.ArrayContainsAll</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ArrayOverlaps">sqlglot.expressions.ArrayOverlaps</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Binary">sqlglot.expressions.Binary</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseAnd">sqlglot.expressions.BitwiseAnd</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseLeftShift">sqlglot.expressions.BitwiseLeftShift</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseOr">sqlglot.expressions.BitwiseOr</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseRightShift">sqlglot.expressions.BitwiseRightShift</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseXor">sqlglot.expressions.BitwiseXor</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Collate">sqlglot.expressions.Collate</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Connector">sqlglot.expressions.Connector</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Corr">sqlglot.expressions.Corr</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#CovarPop">sqlglot.expressions.CovarPop</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#CovarSamp">sqlglot.expressions.CovarSamp</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#DPipe">sqlglot.expressions.DPipe</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Distance">sqlglot.expressions.Distance</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Div">sqlglot.expressions.Div</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Dot">sqlglot.expressions.Dot</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#EQ">sqlglot.expressions.EQ</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Escape">sqlglot.expressions.Escape</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#GT">sqlglot.expressions.GT</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#GTE">sqlglot.expressions.GTE</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Glob">sqlglot.expressions.Glob</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ILike">sqlglot.expressions.ILike</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ILikeAny">sqlglot.expressions.ILikeAny</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#IntDiv">sqlglot.expressions.IntDiv</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Is">sqlglot.expressions.Is</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONArrayContains">sqlglot.expressions.JSONArrayContains</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONBContains">sqlglot.expressions.JSONBContains</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONBExtract">sqlglot.expressions.JSONBExtract</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONBExtractScalar">sqlglot.expressions.JSONBExtractScalar</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONExtract">sqlglot.expressions.JSONExtract</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONExtractScalar">sqlglot.expressions.JSONExtractScalar</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Kwarg">sqlglot.expressions.Kwarg</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#LT">sqlglot.expressions.LT</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#LTE">sqlglot.expressions.LTE</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Like">sqlglot.expressions.Like</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#LikeAny">sqlglot.expressions.LikeAny</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Mod">sqlglot.expressions.Mod</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Mul">sqlglot.expressions.Mul</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#NEQ">sqlglot.expressions.NEQ</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#NullSafeEQ">sqlglot.expressions.NullSafeEQ</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#NullSafeNEQ">sqlglot.expressions.NullSafeNEQ</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Operator">sqlglot.expressions.Operator</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Or">sqlglot.expressions.Or</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Overlaps">sqlglot.expressions.Overlaps</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Pow">sqlglot.expressions.Pow</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#PropertyEQ">sqlglot.expressions.PropertyEQ</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#RegexpILike">sqlglot.expressions.RegexpILike</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#SimilarTo">sqlglot.expressions.SimilarTo</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Slice">sqlglot.expressions.Slice</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Sub">sqlglot.expressions.Sub</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Xor">sqlglot.expressions.Xor</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Length">sqlglot.expressions.Length</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Between">sqlglot.expressions.Between</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#In">sqlglot.expressions.In</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Boolean">sqlglot.expressions.Boolean</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Date">sqlglot.expressions.Date</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeStrToDate">sqlglot.expressions.TimeStrToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentDate">sqlglot.expressions.CurrentDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TsOrDsToDate">sqlglot.expressions.TsOrDsToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#StrToDate">sqlglot.expressions.StrToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DateStrToDate">sqlglot.expressions.DateStrToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DateFromParts">sqlglot.expressions.DateFromParts</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DiToDate">sqlglot.expressions.DiToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Datetime">sqlglot.expressions.Datetime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentDatetime">sqlglot.expressions.CurrentDatetime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DatetimeSub">sqlglot.expressions.DatetimeSub</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DatetimeAdd">sqlglot.expressions.DatetimeAdd</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Log">sqlglot.expressions.Log</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ToDouble">sqlglot.expressions.ToDouble</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#StddevPop">sqlglot.expressions.StddevPop</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Ln">sqlglot.expressions.Ln</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Stddev">sqlglot.expressions.Stddev</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Avg">sqlglot.expressions.Avg</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Sqrt">sqlglot.expressions.Sqrt</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ApproxQuantile">sqlglot.expressions.ApproxQuantile</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Exp">sqlglot.expressions.Exp</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#SafeDivide">sqlglot.expressions.SafeDivide</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Quantile">sqlglot.expressions.Quantile</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Round">sqlglot.expressions.Round</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#StddevSamp">sqlglot.expressions.StddevSamp</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Sign">sqlglot.expressions.Sign</a>'>: <function BigQuery.<lambda>>, <class '<a href="../expressions.html#TsOrDiToDi">sqlglot.expressions.TsOrDiToDi</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DateDiff">sqlglot.expressions.DateDiff</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeDiff">sqlglot.expressions.TimeDiff</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Levenshtein">sqlglot.expressions.Levenshtein</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DateToDi">sqlglot.expressions.DateToDi</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#StrPosition">sqlglot.expressions.StrPosition</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampDiff">sqlglot.expressions.TimestampDiff</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DatetimeDiff">sqlglot.expressions.DatetimeDiff</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Ceil">sqlglot.expressions.Ceil</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Time">sqlglot.expressions.Time</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeStrToTime">sqlglot.expressions.TimeStrToTime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeAdd">sqlglot.expressions.TimeAdd</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeSub">sqlglot.expressions.TimeSub</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampAdd">sqlglot.expressions.TimestampAdd</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#StrToTime">sqlglot.expressions.StrToTime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentTimestamp">sqlglot.expressions.CurrentTimestamp</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampSub">sqlglot.expressions.TimestampSub</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentTime">sqlglot.expressions.CurrentTime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Day">sqlglot.expressions.Day</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Year">sqlglot.expressions.Year</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Quarter">sqlglot.expressions.Quarter</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Week">sqlglot.expressions.Week</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Month">sqlglot.expressions.Month</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#GroupConcat">sqlglot.expressions.GroupConcat</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#String">sqlglot.expressions.String</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Upper">sqlglot.expressions.Upper</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ConcatWs">sqlglot.expressions.ConcatWs</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Concat">sqlglot.expressions.Concat</a>'>: <function BigQuery.<lambda>>, <class '<a href="../expressions.html#Lower">sqlglot.expressions.Lower</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#DateToDateStr">sqlglot.expressions.DateToDateStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Initcap">sqlglot.expressions.Initcap</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeToTimeStr">sqlglot.expressions.TimeToTimeStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Substring">sqlglot.expressions.Substring</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#TsOrDsToDateStr">sqlglot.expressions.TsOrDsToDateStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#UnixToStr">sqlglot.expressions.UnixToStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeToStr">sqlglot.expressions.TimeToStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#ArrayConcat">sqlglot.expressions.ArrayConcat</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#UnixToTimeStr">sqlglot.expressions.UnixToTimeStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Trim">sqlglot.expressions.Trim</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Abs">sqlglot.expressions.Abs</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Anonymous">sqlglot.expressions.Anonymous</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#ArrayAgg">sqlglot.expressions.ArrayAgg</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Bracket">sqlglot.expressions.Bracket</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Cast">sqlglot.expressions.Cast</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Case">sqlglot.expressions.Case</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Coalesce">sqlglot.expressions.Coalesce</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Count">sqlglot.expressions.Count</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#DataType">sqlglot.expressions.DataType</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#DateAdd">sqlglot.expressions.DateAdd</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#DateSub">sqlglot.expressions.DateSub</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#DateTrunc">sqlglot.expressions.DateTrunc</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Distinct">sqlglot.expressions.Distinct</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Extract">sqlglot.expressions.Extract</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Filter">sqlglot.expressions.Filter</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#GenerateDateArray">sqlglot.expressions.GenerateDateArray</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#GenerateTimestampArray">sqlglot.expressions.GenerateTimestampArray</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Greatest">sqlglot.expressions.Greatest</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#If">sqlglot.expressions.If</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Interval">sqlglot.expressions.Interval</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Least">sqlglot.expressions.Least</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Literal">sqlglot.expressions.Literal</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Map">sqlglot.expressions.Map</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Max">sqlglot.expressions.Max</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Min">sqlglot.expressions.Min</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Null">sqlglot.expressions.Null</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Nullif">sqlglot.expressions.Nullif</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Struct">sqlglot.expressions.Struct</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Sum">sqlglot.expressions.Sum</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#TryCast">sqlglot.expressions.TryCast</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Unnest">sqlglot.expressions.Unnest</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#VarMap">sqlglot.expressions.VarMap</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Floor">sqlglot.expressions.Floor</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Left">sqlglot.expressions.Left</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Right">sqlglot.expressions.Right</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Pad">sqlglot.expressions.Pad</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#RegexpExtract">sqlglot.expressions.RegexpExtract</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#RegexpReplace">sqlglot.expressions.RegexpReplace</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Repeat">sqlglot.expressions.Repeat</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>: <function BigQuery.<lambda>>}</span> + <label class="view-value-button pdoc-button" for="BigQuery.ANNOTATORS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#Alias">sqlglot.expressions.Alias</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseNot">sqlglot.expressions.BitwiseNot</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Neg">sqlglot.expressions.Neg</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Not">sqlglot.expressions.Not</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Paren">sqlglot.expressions.Paren</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#PivotAlias">sqlglot.expressions.PivotAlias</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Unary">sqlglot.expressions.Unary</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Add">sqlglot.expressions.Add</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#And">sqlglot.expressions.And</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ArrayContainsAll">sqlglot.expressions.ArrayContainsAll</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ArrayOverlaps">sqlglot.expressions.ArrayOverlaps</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Binary">sqlglot.expressions.Binary</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseAnd">sqlglot.expressions.BitwiseAnd</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseLeftShift">sqlglot.expressions.BitwiseLeftShift</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseOr">sqlglot.expressions.BitwiseOr</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseRightShift">sqlglot.expressions.BitwiseRightShift</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#BitwiseXor">sqlglot.expressions.BitwiseXor</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Collate">sqlglot.expressions.Collate</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Connector">sqlglot.expressions.Connector</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Corr">sqlglot.expressions.Corr</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#CovarPop">sqlglot.expressions.CovarPop</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#CovarSamp">sqlglot.expressions.CovarSamp</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#DPipe">sqlglot.expressions.DPipe</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Distance">sqlglot.expressions.Distance</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Div">sqlglot.expressions.Div</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Dot">sqlglot.expressions.Dot</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#EQ">sqlglot.expressions.EQ</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Escape">sqlglot.expressions.Escape</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#GT">sqlglot.expressions.GT</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#GTE">sqlglot.expressions.GTE</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Glob">sqlglot.expressions.Glob</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ILike">sqlglot.expressions.ILike</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ILikeAny">sqlglot.expressions.ILikeAny</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#IntDiv">sqlglot.expressions.IntDiv</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Is">sqlglot.expressions.Is</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONArrayContains">sqlglot.expressions.JSONArrayContains</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONBContains">sqlglot.expressions.JSONBContains</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONBExtract">sqlglot.expressions.JSONBExtract</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONBExtractScalar">sqlglot.expressions.JSONBExtractScalar</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONExtract">sqlglot.expressions.JSONExtract</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#JSONExtractScalar">sqlglot.expressions.JSONExtractScalar</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Kwarg">sqlglot.expressions.Kwarg</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#LT">sqlglot.expressions.LT</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#LTE">sqlglot.expressions.LTE</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Like">sqlglot.expressions.Like</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#LikeAny">sqlglot.expressions.LikeAny</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Mod">sqlglot.expressions.Mod</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Mul">sqlglot.expressions.Mul</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#NEQ">sqlglot.expressions.NEQ</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#NullSafeEQ">sqlglot.expressions.NullSafeEQ</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#NullSafeNEQ">sqlglot.expressions.NullSafeNEQ</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Operator">sqlglot.expressions.Operator</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Or">sqlglot.expressions.Or</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Overlaps">sqlglot.expressions.Overlaps</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Pow">sqlglot.expressions.Pow</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#PropertyEQ">sqlglot.expressions.PropertyEQ</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#RegexpILike">sqlglot.expressions.RegexpILike</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#SimilarTo">sqlglot.expressions.SimilarTo</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Slice">sqlglot.expressions.Slice</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Sub">sqlglot.expressions.Sub</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Xor">sqlglot.expressions.Xor</a>'>: <function Dialect.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Length">sqlglot.expressions.Length</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Boolean">sqlglot.expressions.Boolean</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#In">sqlglot.expressions.In</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Between">sqlglot.expressions.Between</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentDate">sqlglot.expressions.CurrentDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DateFromParts">sqlglot.expressions.DateFromParts</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Date">sqlglot.expressions.Date</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#StrToDate">sqlglot.expressions.StrToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DateStrToDate">sqlglot.expressions.DateStrToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeStrToDate">sqlglot.expressions.TimeStrToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DiToDate">sqlglot.expressions.DiToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TsOrDsToDate">sqlglot.expressions.TsOrDsToDate</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentDatetime">sqlglot.expressions.CurrentDatetime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Datetime">sqlglot.expressions.Datetime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DatetimeAdd">sqlglot.expressions.DatetimeAdd</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DatetimeSub">sqlglot.expressions.DatetimeSub</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#ApproxQuantile">sqlglot.expressions.ApproxQuantile</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#SafeDivide">sqlglot.expressions.SafeDivide</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Quantile">sqlglot.expressions.Quantile</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Round">sqlglot.expressions.Round</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#StddevSamp">sqlglot.expressions.StddevSamp</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Log">sqlglot.expressions.Log</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#StddevPop">sqlglot.expressions.StddevPop</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Ln">sqlglot.expressions.Ln</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Exp">sqlglot.expressions.Exp</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Stddev">sqlglot.expressions.Stddev</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#ToDouble">sqlglot.expressions.ToDouble</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Sqrt">sqlglot.expressions.Sqrt</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Avg">sqlglot.expressions.Avg</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DateDiff">sqlglot.expressions.DateDiff</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeDiff">sqlglot.expressions.TimeDiff</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DateToDi">sqlglot.expressions.DateToDi</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TsOrDiToDi">sqlglot.expressions.TsOrDiToDi</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#StrPosition">sqlglot.expressions.StrPosition</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampDiff">sqlglot.expressions.TimestampDiff</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#DatetimeDiff">sqlglot.expressions.DatetimeDiff</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Levenshtein">sqlglot.expressions.Levenshtein</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Sign">sqlglot.expressions.Sign</a>'>: <function BigQuery.<lambda>>, <class '<a href="../expressions.html#Ceil">sqlglot.expressions.Ceil</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Time">sqlglot.expressions.Time</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#StrToTime">sqlglot.expressions.StrToTime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeAdd">sqlglot.expressions.TimeAdd</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeSub">sqlglot.expressions.TimeSub</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampAdd">sqlglot.expressions.TimestampAdd</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeStrToTime">sqlglot.expressions.TimeStrToTime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentTimestamp">sqlglot.expressions.CurrentTimestamp</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampSub">sqlglot.expressions.TimestampSub</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentTime">sqlglot.expressions.CurrentTime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Day">sqlglot.expressions.Day</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Month">sqlglot.expressions.Month</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Year">sqlglot.expressions.Year</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Week">sqlglot.expressions.Week</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Quarter">sqlglot.expressions.Quarter</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Lower">sqlglot.expressions.Lower</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#UnixToTimeStr">sqlglot.expressions.UnixToTimeStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeToStr">sqlglot.expressions.TimeToStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Substring">sqlglot.expressions.Substring</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Initcap">sqlglot.expressions.Initcap</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Trim">sqlglot.expressions.Trim</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#UnixToStr">sqlglot.expressions.UnixToStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TsOrDsToDateStr">sqlglot.expressions.TsOrDsToDateStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#ConcatWs">sqlglot.expressions.ConcatWs</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#ArrayConcat">sqlglot.expressions.ArrayConcat</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#DateToDateStr">sqlglot.expressions.DateToDateStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Upper">sqlglot.expressions.Upper</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Concat">sqlglot.expressions.Concat</a>'>: <function BigQuery.<lambda>>, <class '<a href="../expressions.html#GroupConcat">sqlglot.expressions.GroupConcat</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#String">sqlglot.expressions.String</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#TimeToTimeStr">sqlglot.expressions.TimeToTimeStr</a>'>: <function _annotate_with_type_lambda.<locals>.<lambda>>, <class '<a href="../expressions.html#Abs">sqlglot.expressions.Abs</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Anonymous">sqlglot.expressions.Anonymous</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#ArrayAgg">sqlglot.expressions.ArrayAgg</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Bracket">sqlglot.expressions.Bracket</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Cast">sqlglot.expressions.Cast</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Case">sqlglot.expressions.Case</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Coalesce">sqlglot.expressions.Coalesce</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Count">sqlglot.expressions.Count</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#DataType">sqlglot.expressions.DataType</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#DateAdd">sqlglot.expressions.DateAdd</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#DateSub">sqlglot.expressions.DateSub</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#DateTrunc">sqlglot.expressions.DateTrunc</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Distinct">sqlglot.expressions.Distinct</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Extract">sqlglot.expressions.Extract</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Filter">sqlglot.expressions.Filter</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#GenerateDateArray">sqlglot.expressions.GenerateDateArray</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#GenerateTimestampArray">sqlglot.expressions.GenerateTimestampArray</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Greatest">sqlglot.expressions.Greatest</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#If">sqlglot.expressions.If</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Interval">sqlglot.expressions.Interval</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Least">sqlglot.expressions.Least</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Literal">sqlglot.expressions.Literal</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Map">sqlglot.expressions.Map</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Max">sqlglot.expressions.Max</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Min">sqlglot.expressions.Min</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Null">sqlglot.expressions.Null</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Nullif">sqlglot.expressions.Nullif</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Struct">sqlglot.expressions.Struct</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Sum">sqlglot.expressions.Sum</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#TryCast">sqlglot.expressions.TryCast</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Unnest">sqlglot.expressions.Unnest</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#VarMap">sqlglot.expressions.VarMap</a>'>: <function Dialect.<lambda>>, <class '<a href="../expressions.html#Floor">sqlglot.expressions.Floor</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Left">sqlglot.expressions.Left</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Right">sqlglot.expressions.Right</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Pad">sqlglot.expressions.Pad</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#RegexpExtract">sqlglot.expressions.RegexpExtract</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#RegexpReplace">sqlglot.expressions.RegexpReplace</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Repeat">sqlglot.expressions.Repeat</a>'>: <function BigQuery.<dictcomp>.<lambda>>, <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>: <function BigQuery.<lambda>>}</span> </div> @@ -3574,241 +3585,245 @@ that it can analyze queries in the optimizer and successfully capture their sema </span><span id="BigQuery.Parser-590"><a href="#BigQuery.Parser-590"><span class="linenos">590</span></a> </span><span id="BigQuery.Parser-591"><a href="#BigQuery.Parser-591"><span class="linenos">591</span></a> <span class="n">NULL_TOKENS</span> <span class="o">=</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">UNKNOWN</span><span class="p">}</span> </span><span id="BigQuery.Parser-592"><a href="#BigQuery.Parser-592"><span class="linenos">592</span></a> -</span><span id="BigQuery.Parser-593"><a href="#BigQuery.Parser-593"><span class="linenos">593</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Parser-594"><a href="#BigQuery.Parser-594"><span class="linenos">594</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> -</span><span id="BigQuery.Parser-595"><a href="#BigQuery.Parser-595"><span class="linenos">595</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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="BigQuery.Parser-596"><a href="#BigQuery.Parser-596"><span class="linenos">596</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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="BigQuery.Parser-597"><a href="#BigQuery.Parser-597"><span class="linenos">597</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">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">_parse_for_in</span><span class="p">(),</span> -</span><span id="BigQuery.Parser-598"><a href="#BigQuery.Parser-598"><span class="linenos">598</span></a> <span class="p">}</span> -</span><span id="BigQuery.Parser-599"><a href="#BigQuery.Parser-599"><span class="linenos">599</span></a> -</span><span id="BigQuery.Parser-600"><a href="#BigQuery.Parser-600"><span class="linenos">600</span></a> <span class="n">BRACKET_OFFSETS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Parser-601"><a href="#BigQuery.Parser-601"><span class="linenos">601</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> -</span><span id="BigQuery.Parser-602"><a href="#BigQuery.Parser-602"><span class="linenos">602</span></a> <span class="s2">"ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> -</span><span id="BigQuery.Parser-603"><a href="#BigQuery.Parser-603"><span class="linenos">603</span></a> <span class="s2">"SAFE_OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="BigQuery.Parser-604"><a href="#BigQuery.Parser-604"><span class="linenos">604</span></a> <span class="s2">"SAFE_ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="BigQuery.Parser-605"><a href="#BigQuery.Parser-605"><span class="linenos">605</span></a> <span class="p">}</span> -</span><span id="BigQuery.Parser-606"><a href="#BigQuery.Parser-606"><span class="linenos">606</span></a> -</span><span id="BigQuery.Parser-607"><a href="#BigQuery.Parser-607"><span class="linenos">607</span></a> <span class="k">def</span> <span class="nf">_parse_for_in</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">:</span> -</span><span id="BigQuery.Parser-608"><a href="#BigQuery.Parser-608"><span class="linenos">608</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">()</span> -</span><span id="BigQuery.Parser-609"><a href="#BigQuery.Parser-609"><span class="linenos">609</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="BigQuery.Parser-610"><a href="#BigQuery.Parser-610"><span class="linenos">610</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span 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_statement</span><span class="p">())</span> -</span><span id="BigQuery.Parser-611"><a href="#BigQuery.Parser-611"><span class="linenos">611</span></a> -</span><span id="BigQuery.Parser-612"><a href="#BigQuery.Parser-612"><span class="linenos">612</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="BigQuery.Parser-613"><a href="#BigQuery.Parser-613"><span class="linenos">613</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="BigQuery.Parser-614"><a href="#BigQuery.Parser-614"><span class="linenos">614</span></a> -</span><span id="BigQuery.Parser-615"><a href="#BigQuery.Parser-615"><span class="linenos">615</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> -</span><span id="BigQuery.Parser-616"><a href="#BigQuery.Parser-616"><span class="linenos">616</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> -</span><span id="BigQuery.Parser-617"><a href="#BigQuery.Parser-617"><span class="linenos">617</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="BigQuery.Parser-618"><a href="#BigQuery.Parser-618"><span class="linenos">618</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="BigQuery.Parser-619"><a href="#BigQuery.Parser-619"><span class="linenos">619</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="BigQuery.Parser-620"><a href="#BigQuery.Parser-620"><span class="linenos">620</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</span><span class="p">()</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="o">!=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">:</span> -</span><span id="BigQuery.Parser-621"><a href="#BigQuery.Parser-621"><span class="linenos">621</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="BigQuery.Parser-622"><a href="#BigQuery.Parser-622"><span class="linenos">622</span></a> <span class="n">text</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="BigQuery.Parser-623"><a href="#BigQuery.Parser-623"><span class="linenos">623</span></a> <span class="n">table_name</span> <span class="o">+=</span> <span class="n">text</span> -</span><span id="BigQuery.Parser-624"><a href="#BigQuery.Parser-624"><span class="linenos">624</span></a> -</span><span id="BigQuery.Parser-625"><a href="#BigQuery.Parser-625"><span class="linenos">625</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> -</span><span id="BigQuery.Parser-626"><a href="#BigQuery.Parser-626"><span class="linenos">626</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">Literal</span><span class="p">):</span> -</span><span id="BigQuery.Parser-627"><a href="#BigQuery.Parser-627"><span class="linenos">627</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="BigQuery.Parser-593"><a href="#BigQuery.Parser-593"><span class="linenos">593</span></a> <span class="n">DASHED_TABLE_PART_FOLLOW_TOKENS</span> <span class="o">=</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">L_PAREN</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="BigQuery.Parser-594"><a href="#BigQuery.Parser-594"><span class="linenos">594</span></a> +</span><span id="BigQuery.Parser-595"><a href="#BigQuery.Parser-595"><span class="linenos">595</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Parser-596"><a href="#BigQuery.Parser-596"><span class="linenos">596</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> +</span><span id="BigQuery.Parser-597"><a href="#BigQuery.Parser-597"><span class="linenos">597</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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="BigQuery.Parser-598"><a href="#BigQuery.Parser-598"><span class="linenos">598</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</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="BigQuery.Parser-599"><a href="#BigQuery.Parser-599"><span class="linenos">599</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">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">_parse_for_in</span><span class="p">(),</span> +</span><span id="BigQuery.Parser-600"><a href="#BigQuery.Parser-600"><span class="linenos">600</span></a> <span class="p">}</span> +</span><span id="BigQuery.Parser-601"><a href="#BigQuery.Parser-601"><span class="linenos">601</span></a> +</span><span id="BigQuery.Parser-602"><a href="#BigQuery.Parser-602"><span class="linenos">602</span></a> <span class="n">BRACKET_OFFSETS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Parser-603"><a href="#BigQuery.Parser-603"><span class="linenos">603</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> +</span><span id="BigQuery.Parser-604"><a href="#BigQuery.Parser-604"><span class="linenos">604</span></a> <span class="s2">"ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">False</span><span class="p">),</span> +</span><span id="BigQuery.Parser-605"><a href="#BigQuery.Parser-605"><span class="linenos">605</span></a> <span class="s2">"SAFE_OFFSET"</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="BigQuery.Parser-606"><a href="#BigQuery.Parser-606"><span class="linenos">606</span></a> <span class="s2">"SAFE_ORDINAL"</span><span class="p">:</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="BigQuery.Parser-607"><a href="#BigQuery.Parser-607"><span class="linenos">607</span></a> <span class="p">}</span> +</span><span id="BigQuery.Parser-608"><a href="#BigQuery.Parser-608"><span class="linenos">608</span></a> +</span><span id="BigQuery.Parser-609"><a href="#BigQuery.Parser-609"><span class="linenos">609</span></a> <span class="k">def</span> <span class="nf">_parse_for_in</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">:</span> +</span><span id="BigQuery.Parser-610"><a href="#BigQuery.Parser-610"><span class="linenos">610</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">()</span> +</span><span id="BigQuery.Parser-611"><a href="#BigQuery.Parser-611"><span class="linenos">611</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="BigQuery.Parser-612"><a href="#BigQuery.Parser-612"><span class="linenos">612</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span 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_statement</span><span class="p">())</span> +</span><span id="BigQuery.Parser-613"><a href="#BigQuery.Parser-613"><span class="linenos">613</span></a> +</span><span id="BigQuery.Parser-614"><a href="#BigQuery.Parser-614"><span class="linenos">614</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="BigQuery.Parser-615"><a href="#BigQuery.Parser-615"><span class="linenos">615</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="BigQuery.Parser-616"><a href="#BigQuery.Parser-616"><span class="linenos">616</span></a> +</span><span id="BigQuery.Parser-617"><a href="#BigQuery.Parser-617"><span class="linenos">617</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> +</span><span id="BigQuery.Parser-618"><a href="#BigQuery.Parser-618"><span class="linenos">618</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> +</span><span id="BigQuery.Parser-619"><a href="#BigQuery.Parser-619"><span class="linenos">619</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="BigQuery.Parser-620"><a href="#BigQuery.Parser-620"><span class="linenos">620</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="BigQuery.Parser-621"><a href="#BigQuery.Parser-621"><span class="linenos">621</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="BigQuery.Parser-622"><a href="#BigQuery.Parser-622"><span class="linenos">622</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</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_set</span><span class="p">(</span> +</span><span id="BigQuery.Parser-623"><a href="#BigQuery.Parser-623"><span class="linenos">623</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">DASHED_TABLE_PART_FOLLOW_TOKENS</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span> +</span><span id="BigQuery.Parser-624"><a href="#BigQuery.Parser-624"><span class="linenos">624</span></a> <span class="p">):</span> +</span><span id="BigQuery.Parser-625"><a href="#BigQuery.Parser-625"><span class="linenos">625</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="BigQuery.Parser-626"><a href="#BigQuery.Parser-626"><span class="linenos">626</span></a> +</span><span id="BigQuery.Parser-627"><a href="#BigQuery.Parser-627"><span class="linenos">627</span></a> <span class="n">table_name</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="BigQuery.Parser-628"><a href="#BigQuery.Parser-628"><span class="linenos">628</span></a> -</span><span id="BigQuery.Parser-629"><a href="#BigQuery.Parser-629"><span class="linenos">629</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</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 class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="BigQuery.Parser-630"><a href="#BigQuery.Parser-630"><span class="linenos">630</span></a> <span class="n">table_name</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="BigQuery.Parser-631"><a href="#BigQuery.Parser-631"><span class="linenos">631</span></a> -</span><span id="BigQuery.Parser-632"><a href="#BigQuery.Parser-632"><span class="linenos">632</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="BigQuery.Parser-633"><a href="#BigQuery.Parser-633"><span class="linenos">633</span></a> -</span><span id="BigQuery.Parser-634"><a href="#BigQuery.Parser-634"><span class="linenos">634</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="BigQuery.Parser-629"><a href="#BigQuery.Parser-629"><span class="linenos">629</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> +</span><span id="BigQuery.Parser-630"><a href="#BigQuery.Parser-630"><span class="linenos">630</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">Literal</span><span class="p">):</span> +</span><span id="BigQuery.Parser-631"><a href="#BigQuery.Parser-631"><span class="linenos">631</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="BigQuery.Parser-632"><a href="#BigQuery.Parser-632"><span class="linenos">632</span></a> +</span><span id="BigQuery.Parser-633"><a href="#BigQuery.Parser-633"><span class="linenos">633</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_connected</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 class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="BigQuery.Parser-634"><a href="#BigQuery.Parser-634"><span class="linenos">634</span></a> <span class="n">table_name</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="BigQuery.Parser-635"><a href="#BigQuery.Parser-635"><span class="linenos">635</span></a> -</span><span id="BigQuery.Parser-636"><a href="#BigQuery.Parser-636"><span class="linenos">636</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span> -</span><span id="BigQuery.Parser-637"><a href="#BigQuery.Parser-637"><span class="linenos">637</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">is_db_reference</span><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">wildcard</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Parser-638"><a href="#BigQuery.Parser-638"><span class="linenos">638</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="BigQuery.Parser-639"><a href="#BigQuery.Parser-639"><span class="linenos">639</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span> -</span><span id="BigQuery.Parser-640"><a href="#BigQuery.Parser-640"><span class="linenos">640</span></a> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">,</span> <span class="n">is_db_reference</span><span class="o">=</span><span class="n">is_db_reference</span><span class="p">,</span> <span class="n">wildcard</span><span class="o">=</span><span class="kc">True</span> -</span><span id="BigQuery.Parser-641"><a href="#BigQuery.Parser-641"><span class="linenos">641</span></a> <span class="p">)</span> -</span><span id="BigQuery.Parser-642"><a href="#BigQuery.Parser-642"><span class="linenos">642</span></a> -</span><span id="BigQuery.Parser-643"><a href="#BigQuery.Parser-643"><span class="linenos">643</span></a> <span class="c1"># proj-1.db.tbl -- `1.` is tokenized as a float so we need to unravel it here</span> -</span><span id="BigQuery.Parser-644"><a href="#BigQuery.Parser-644"><span class="linenos">644</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">catalog</span><span class="p">:</span> -</span><span id="BigQuery.Parser-645"><a href="#BigQuery.Parser-645"><span class="linenos">645</span></a> <span class="k">if</span> <span class="n">table</span><span class="o">.</span><span class="n">db</span><span class="p">:</span> -</span><span id="BigQuery.Parser-646"><a href="#BigQuery.Parser-646"><span class="linenos">646</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">db</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="BigQuery.Parser-647"><a href="#BigQuery.Parser-647"><span class="linenos">647</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"db"</span><span class="p">]</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> -</span><span id="BigQuery.Parser-648"><a href="#BigQuery.Parser-648"><span class="linenos">648</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> -</span><span id="BigQuery.Parser-649"><a href="#BigQuery.Parser-649"><span class="linenos">649</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> -</span><span id="BigQuery.Parser-650"><a href="#BigQuery.Parser-650"><span class="linenos">650</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="BigQuery.Parser-651"><a href="#BigQuery.Parser-651"><span class="linenos">651</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">name</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="BigQuery.Parser-652"><a href="#BigQuery.Parser-652"><span class="linenos">652</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> -</span><span id="BigQuery.Parser-653"><a href="#BigQuery.Parser-653"><span class="linenos">653</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> -</span><span id="BigQuery.Parser-654"><a href="#BigQuery.Parser-654"><span class="linenos">654</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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="BigQuery.Parser-655"><a href="#BigQuery.Parser-655"><span class="linenos">655</span></a> -</span><span id="BigQuery.Parser-656"><a href="#BigQuery.Parser-656"><span class="linenos">656</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">):</span> -</span><span id="BigQuery.Parser-657"><a href="#BigQuery.Parser-657"><span class="linenos">657</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery.Parser-658"><a href="#BigQuery.Parser-658"><span class="linenos">658</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="BigQuery.Parser-659"><a href="#BigQuery.Parser-659"><span class="linenos">659</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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="BigQuery.Parser-660"><a href="#BigQuery.Parser-660"><span class="linenos">660</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> -</span><span id="BigQuery.Parser-661"><a href="#BigQuery.Parser-661"><span class="linenos">661</span></a> <span class="p">)</span> -</span><span id="BigQuery.Parser-662"><a href="#BigQuery.Parser-662"><span class="linenos">662</span></a> -</span><span id="BigQuery.Parser-663"><a href="#BigQuery.Parser-663"><span class="linenos">663</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> -</span><span id="BigQuery.Parser-664"><a href="#BigQuery.Parser-664"><span class="linenos">664</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> -</span><span id="BigQuery.Parser-665"><a href="#BigQuery.Parser-665"><span class="linenos">665</span></a> -</span><span id="BigQuery.Parser-666"><a href="#BigQuery.Parser-666"><span class="linenos">666</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span> -</span><span id="BigQuery.Parser-667"><a href="#BigQuery.Parser-667"><span class="linenos">667</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">)</span> -</span><span id="BigQuery.Parser-668"><a href="#BigQuery.Parser-668"><span class="linenos">668</span></a> <span class="p">)</span> -</span><span id="BigQuery.Parser-669"><a href="#BigQuery.Parser-669"><span class="linenos">669</span></a> <span class="n">table</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_table"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Parser-670"><a href="#BigQuery.Parser-670"><span class="linenos">670</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="BigQuery.Parser-671"><a href="#BigQuery.Parser-671"><span class="linenos">671</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="BigQuery.Parser-672"><a href="#BigQuery.Parser-672"><span class="linenos">672</span></a> -</span><span id="BigQuery.Parser-673"><a href="#BigQuery.Parser-673"><span class="linenos">673</span></a> <span class="c1"># The `INFORMATION_SCHEMA` views in BigQuery need to be qualified by a region or</span> -</span><span id="BigQuery.Parser-674"><a href="#BigQuery.Parser-674"><span class="linenos">674</span></a> <span class="c1"># dataset, so if the project identifier is omitted we need to fix the ast so that</span> -</span><span id="BigQuery.Parser-675"><a href="#BigQuery.Parser-675"><span class="linenos">675</span></a> <span class="c1"># the `INFORMATION_SCHEMA.X` bit is represented as a single (quoted) Identifier.</span> -</span><span id="BigQuery.Parser-676"><a href="#BigQuery.Parser-676"><span class="linenos">676</span></a> <span class="c1"># Otherwise, we wouldn't correctly qualify a `Table` node that references these</span> -</span><span id="BigQuery.Parser-677"><a href="#BigQuery.Parser-677"><span class="linenos">677</span></a> <span class="c1"># views, because it would seem like the "catalog" part is set, when it'd actually</span> -</span><span id="BigQuery.Parser-678"><a href="#BigQuery.Parser-678"><span class="linenos">678</span></a> <span class="c1"># be the region/dataset. Merging the two identifiers into a single one is done to</span> -</span><span id="BigQuery.Parser-679"><a href="#BigQuery.Parser-679"><span class="linenos">679</span></a> <span class="c1"># avoid producing a 4-part Table reference, which would cause issues in the schema</span> -</span><span id="BigQuery.Parser-680"><a href="#BigQuery.Parser-680"><span class="linenos">680</span></a> <span class="c1"># module, when there are 3-part table names mixed with information schema views.</span> -</span><span id="BigQuery.Parser-681"><a href="#BigQuery.Parser-681"><span class="linenos">681</span></a> <span class="c1">#</span> -</span><span id="BigQuery.Parser-682"><a href="#BigQuery.Parser-682"><span class="linenos">682</span></a> <span class="c1"># See: https://cloud.google.com/bigquery/docs/information-schema-intro#syntax</span> -</span><span id="BigQuery.Parser-683"><a href="#BigQuery.Parser-683"><span class="linenos">683</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span> -</span><span id="BigQuery.Parser-684"><a href="#BigQuery.Parser-684"><span class="linenos">684</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">table_parts</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"INFORMATION_SCHEMA"</span><span class="p">:</span> -</span><span id="BigQuery.Parser-685"><a href="#BigQuery.Parser-685"><span class="linenos">685</span></a> <span class="c1"># We need to alias the table here to avoid breaking existing qualified columns.</span> -</span><span id="BigQuery.Parser-686"><a href="#BigQuery.Parser-686"><span class="linenos">686</span></a> <span class="c1"># This is expected to be safe, because if there's an actual alias coming up in</span> -</span><span id="BigQuery.Parser-687"><a href="#BigQuery.Parser-687"><span class="linenos">687</span></a> <span class="c1"># the token stream, it will overwrite this one. If there isn't one, we are only</span> -</span><span id="BigQuery.Parser-688"><a href="#BigQuery.Parser-688"><span class="linenos">688</span></a> <span class="c1"># exposing the name that can be used to reference the view explicitly (a no-op).</span> -</span><span id="BigQuery.Parser-689"><a href="#BigQuery.Parser-689"><span class="linenos">689</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span> -</span><span id="BigQuery.Parser-690"><a href="#BigQuery.Parser-690"><span class="linenos">690</span></a> <span class="n">table</span><span class="p">,</span> -</span><span id="BigQuery.Parser-691"><a href="#BigQuery.Parser-691"><span class="linenos">691</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">Identifier</span><span class="p">,</span> <span class="n">alias</span> <span class="ow">or</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]),</span> -</span><span id="BigQuery.Parser-692"><a href="#BigQuery.Parser-692"><span class="linenos">692</span></a> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="BigQuery.Parser-693"><a href="#BigQuery.Parser-693"><span class="linenos">693</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="BigQuery.Parser-694"><a href="#BigQuery.Parser-694"><span class="linenos">694</span></a> <span class="p">)</span> -</span><span id="BigQuery.Parser-695"><a href="#BigQuery.Parser-695"><span class="linenos">695</span></a> -</span><span id="BigQuery.Parser-696"><a href="#BigQuery.Parser-696"><span class="linenos">696</span></a> <span class="n">info_schema_view</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">table_parts</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">name</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Parser-697"><a href="#BigQuery.Parser-697"><span class="linenos">697</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">info_schema_view</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="BigQuery.Parser-698"><a href="#BigQuery.Parser-698"><span class="linenos">698</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">))</span> -</span><span id="BigQuery.Parser-699"><a href="#BigQuery.Parser-699"><span class="linenos">699</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">4</span><span class="p">))</span> -</span><span id="BigQuery.Parser-700"><a href="#BigQuery.Parser-700"><span class="linenos">700</span></a> -</span><span id="BigQuery.Parser-701"><a href="#BigQuery.Parser-701"><span class="linenos">701</span></a> <span class="k">return</span> <span class="n">table</span> -</span><span id="BigQuery.Parser-702"><a href="#BigQuery.Parser-702"><span class="linenos">702</span></a> -</span><span id="BigQuery.Parser-703"><a href="#BigQuery.Parser-703"><span class="linenos">703</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="BigQuery.Parser-704"><a href="#BigQuery.Parser-704"><span class="linenos">704</span></a> <span class="n">column</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="BigQuery.Parser-705"><a href="#BigQuery.Parser-705"><span class="linenos">705</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="BigQuery.Parser-706"><a href="#BigQuery.Parser-706"><span class="linenos">706</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span> -</span><span id="BigQuery.Parser-707"><a href="#BigQuery.Parser-707"><span class="linenos">707</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">):</span> -</span><span id="BigQuery.Parser-708"><a href="#BigQuery.Parser-708"><span class="linenos">708</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="BigQuery.Parser-709"><a href="#BigQuery.Parser-709"><span class="linenos">709</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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="BigQuery.Parser-710"><a href="#BigQuery.Parser-710"><span class="linenos">710</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> -</span><span id="BigQuery.Parser-711"><a href="#BigQuery.Parser-711"><span class="linenos">711</span></a> <span class="p">)</span> -</span><span id="BigQuery.Parser-712"><a href="#BigQuery.Parser-712"><span class="linenos">712</span></a> -</span><span id="BigQuery.Parser-713"><a href="#BigQuery.Parser-713"><span class="linenos">713</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> -</span><span id="BigQuery.Parser-714"><a href="#BigQuery.Parser-714"><span class="linenos">714</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> -</span><span id="BigQuery.Parser-715"><a href="#BigQuery.Parser-715"><span class="linenos">715</span></a> -</span><span id="BigQuery.Parser-716"><a href="#BigQuery.Parser-716"><span class="linenos">716</span></a> <span class="n">column</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">table</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><span id="BigQuery.Parser-717"><a href="#BigQuery.Parser-717"><span class="linenos">717</span></a> <span class="n">column</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_column"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Parser-718"><a href="#BigQuery.Parser-718"><span class="linenos">718</span></a> -</span><span id="BigQuery.Parser-719"><a href="#BigQuery.Parser-719"><span class="linenos">719</span></a> <span class="k">return</span> <span class="n">column</span> -</span><span id="BigQuery.Parser-720"><a href="#BigQuery.Parser-720"><span class="linenos">720</span></a> -</span><span id="BigQuery.Parser-721"><a href="#BigQuery.Parser-721"><span class="linenos">721</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="BigQuery.Parser-722"><a href="#BigQuery.Parser-722"><span class="linenos">722</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObject</span><span class="p">:</span> <span class="o">...</span> -</span><span id="BigQuery.Parser-723"><a href="#BigQuery.Parser-723"><span class="linenos">723</span></a> -</span><span id="BigQuery.Parser-724"><a href="#BigQuery.Parser-724"><span class="linenos">724</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="BigQuery.Parser-725"><a href="#BigQuery.Parser-725"><span class="linenos">725</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObjectAgg</span><span class="p">:</span> <span class="o">...</span> -</span><span id="BigQuery.Parser-726"><a href="#BigQuery.Parser-726"><span class="linenos">726</span></a> -</span><span id="BigQuery.Parser-727"><a href="#BigQuery.Parser-727"><span class="linenos">727</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="n">agg</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> -</span><span id="BigQuery.Parser-728"><a href="#BigQuery.Parser-728"><span class="linenos">728</span></a> <span class="n">json_object</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_json_object</span><span class="p">()</span> -</span><span id="BigQuery.Parser-729"><a href="#BigQuery.Parser-729"><span class="linenos">729</span></a> <span class="n">array_kv_pair</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">json_object</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="BigQuery.Parser-636"><a href="#BigQuery.Parser-636"><span class="linenos">636</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="BigQuery.Parser-637"><a href="#BigQuery.Parser-637"><span class="linenos">637</span></a> +</span><span id="BigQuery.Parser-638"><a href="#BigQuery.Parser-638"><span class="linenos">638</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="BigQuery.Parser-639"><a href="#BigQuery.Parser-639"><span class="linenos">639</span></a> +</span><span id="BigQuery.Parser-640"><a href="#BigQuery.Parser-640"><span class="linenos">640</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span> +</span><span id="BigQuery.Parser-641"><a href="#BigQuery.Parser-641"><span class="linenos">641</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">is_db_reference</span><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">wildcard</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Parser-642"><a href="#BigQuery.Parser-642"><span class="linenos">642</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="BigQuery.Parser-643"><a href="#BigQuery.Parser-643"><span class="linenos">643</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span> +</span><span id="BigQuery.Parser-644"><a href="#BigQuery.Parser-644"><span class="linenos">644</span></a> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">,</span> <span class="n">is_db_reference</span><span class="o">=</span><span class="n">is_db_reference</span><span class="p">,</span> <span class="n">wildcard</span><span class="o">=</span><span class="kc">True</span> +</span><span id="BigQuery.Parser-645"><a href="#BigQuery.Parser-645"><span class="linenos">645</span></a> <span class="p">)</span> +</span><span id="BigQuery.Parser-646"><a href="#BigQuery.Parser-646"><span class="linenos">646</span></a> +</span><span id="BigQuery.Parser-647"><a href="#BigQuery.Parser-647"><span class="linenos">647</span></a> <span class="c1"># proj-1.db.tbl -- `1.` is tokenized as a float so we need to unravel it here</span> +</span><span id="BigQuery.Parser-648"><a href="#BigQuery.Parser-648"><span class="linenos">648</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">catalog</span><span class="p">:</span> +</span><span id="BigQuery.Parser-649"><a href="#BigQuery.Parser-649"><span class="linenos">649</span></a> <span class="k">if</span> <span class="n">table</span><span class="o">.</span><span class="n">db</span><span class="p">:</span> +</span><span id="BigQuery.Parser-650"><a href="#BigQuery.Parser-650"><span class="linenos">650</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">db</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="BigQuery.Parser-651"><a href="#BigQuery.Parser-651"><span class="linenos">651</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"db"</span><span class="p">]</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> +</span><span id="BigQuery.Parser-652"><a href="#BigQuery.Parser-652"><span class="linenos">652</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> +</span><span id="BigQuery.Parser-653"><a href="#BigQuery.Parser-653"><span class="linenos">653</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span> +</span><span id="BigQuery.Parser-654"><a href="#BigQuery.Parser-654"><span class="linenos">654</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="BigQuery.Parser-655"><a href="#BigQuery.Parser-655"><span class="linenos">655</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">name</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="BigQuery.Parser-656"><a href="#BigQuery.Parser-656"><span class="linenos">656</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="ow">and</span> <span class="ow">not</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> +</span><span id="BigQuery.Parser-657"><a href="#BigQuery.Parser-657"><span class="linenos">657</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span> +</span><span id="BigQuery.Parser-658"><a href="#BigQuery.Parser-658"><span class="linenos">658</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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="BigQuery.Parser-659"><a href="#BigQuery.Parser-659"><span class="linenos">659</span></a> +</span><span id="BigQuery.Parser-660"><a href="#BigQuery.Parser-660"><span class="linenos">660</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">):</span> +</span><span id="BigQuery.Parser-661"><a href="#BigQuery.Parser-661"><span class="linenos">661</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Parser-662"><a href="#BigQuery.Parser-662"><span class="linenos">662</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="BigQuery.Parser-663"><a href="#BigQuery.Parser-663"><span class="linenos">663</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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="BigQuery.Parser-664"><a href="#BigQuery.Parser-664"><span class="linenos">664</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> +</span><span id="BigQuery.Parser-665"><a href="#BigQuery.Parser-665"><span class="linenos">665</span></a> <span class="p">)</span> +</span><span id="BigQuery.Parser-666"><a href="#BigQuery.Parser-666"><span class="linenos">666</span></a> +</span><span id="BigQuery.Parser-667"><a href="#BigQuery.Parser-667"><span class="linenos">667</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> +</span><span id="BigQuery.Parser-668"><a href="#BigQuery.Parser-668"><span class="linenos">668</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> +</span><span id="BigQuery.Parser-669"><a href="#BigQuery.Parser-669"><span class="linenos">669</span></a> +</span><span id="BigQuery.Parser-670"><a href="#BigQuery.Parser-670"><span class="linenos">670</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span> +</span><span id="BigQuery.Parser-671"><a href="#BigQuery.Parser-671"><span class="linenos">671</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">)</span> +</span><span id="BigQuery.Parser-672"><a href="#BigQuery.Parser-672"><span class="linenos">672</span></a> <span class="p">)</span> +</span><span id="BigQuery.Parser-673"><a href="#BigQuery.Parser-673"><span class="linenos">673</span></a> <span class="n">table</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_table"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Parser-674"><a href="#BigQuery.Parser-674"><span class="linenos">674</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="BigQuery.Parser-675"><a href="#BigQuery.Parser-675"><span class="linenos">675</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="BigQuery.Parser-676"><a href="#BigQuery.Parser-676"><span class="linenos">676</span></a> +</span><span id="BigQuery.Parser-677"><a href="#BigQuery.Parser-677"><span class="linenos">677</span></a> <span class="c1"># The `INFORMATION_SCHEMA` views in BigQuery need to be qualified by a region or</span> +</span><span id="BigQuery.Parser-678"><a href="#BigQuery.Parser-678"><span class="linenos">678</span></a> <span class="c1"># dataset, so if the project identifier is omitted we need to fix the ast so that</span> +</span><span id="BigQuery.Parser-679"><a href="#BigQuery.Parser-679"><span class="linenos">679</span></a> <span class="c1"># the `INFORMATION_SCHEMA.X` bit is represented as a single (quoted) Identifier.</span> +</span><span id="BigQuery.Parser-680"><a href="#BigQuery.Parser-680"><span class="linenos">680</span></a> <span class="c1"># Otherwise, we wouldn't correctly qualify a `Table` node that references these</span> +</span><span id="BigQuery.Parser-681"><a href="#BigQuery.Parser-681"><span class="linenos">681</span></a> <span class="c1"># views, because it would seem like the "catalog" part is set, when it'd actually</span> +</span><span id="BigQuery.Parser-682"><a href="#BigQuery.Parser-682"><span class="linenos">682</span></a> <span class="c1"># be the region/dataset. Merging the two identifiers into a single one is done to</span> +</span><span id="BigQuery.Parser-683"><a href="#BigQuery.Parser-683"><span class="linenos">683</span></a> <span class="c1"># avoid producing a 4-part Table reference, which would cause issues in the schema</span> +</span><span id="BigQuery.Parser-684"><a href="#BigQuery.Parser-684"><span class="linenos">684</span></a> <span class="c1"># module, when there are 3-part table names mixed with information schema views.</span> +</span><span id="BigQuery.Parser-685"><a href="#BigQuery.Parser-685"><span class="linenos">685</span></a> <span class="c1">#</span> +</span><span id="BigQuery.Parser-686"><a href="#BigQuery.Parser-686"><span class="linenos">686</span></a> <span class="c1"># See: https://cloud.google.com/bigquery/docs/information-schema-intro#syntax</span> +</span><span id="BigQuery.Parser-687"><a href="#BigQuery.Parser-687"><span class="linenos">687</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">parts</span> +</span><span id="BigQuery.Parser-688"><a href="#BigQuery.Parser-688"><span class="linenos">688</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">table_parts</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"INFORMATION_SCHEMA"</span><span class="p">:</span> +</span><span id="BigQuery.Parser-689"><a href="#BigQuery.Parser-689"><span class="linenos">689</span></a> <span class="c1"># We need to alias the table here to avoid breaking existing qualified columns.</span> +</span><span id="BigQuery.Parser-690"><a href="#BigQuery.Parser-690"><span class="linenos">690</span></a> <span class="c1"># This is expected to be safe, because if there's an actual alias coming up in</span> +</span><span id="BigQuery.Parser-691"><a href="#BigQuery.Parser-691"><span class="linenos">691</span></a> <span class="c1"># the token stream, it will overwrite this one. If there isn't one, we are only</span> +</span><span id="BigQuery.Parser-692"><a href="#BigQuery.Parser-692"><span class="linenos">692</span></a> <span class="c1"># exposing the name that can be used to reference the view explicitly (a no-op).</span> +</span><span id="BigQuery.Parser-693"><a href="#BigQuery.Parser-693"><span class="linenos">693</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span> +</span><span id="BigQuery.Parser-694"><a href="#BigQuery.Parser-694"><span class="linenos">694</span></a> <span class="n">table</span><span class="p">,</span> +</span><span id="BigQuery.Parser-695"><a href="#BigQuery.Parser-695"><span class="linenos">695</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">Identifier</span><span class="p">,</span> <span class="n">alias</span> <span class="ow">or</span> <span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]),</span> +</span><span id="BigQuery.Parser-696"><a href="#BigQuery.Parser-696"><span class="linenos">696</span></a> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="BigQuery.Parser-697"><a href="#BigQuery.Parser-697"><span class="linenos">697</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="BigQuery.Parser-698"><a href="#BigQuery.Parser-698"><span class="linenos">698</span></a> <span class="p">)</span> +</span><span id="BigQuery.Parser-699"><a href="#BigQuery.Parser-699"><span class="linenos">699</span></a> +</span><span id="BigQuery.Parser-700"><a href="#BigQuery.Parser-700"><span class="linenos">700</span></a> <span class="n">info_schema_view</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_parts</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">table_parts</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">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Parser-701"><a href="#BigQuery.Parser-701"><span class="linenos">701</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">info_schema_view</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="BigQuery.Parser-702"><a href="#BigQuery.Parser-702"><span class="linenos">702</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"db"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">3</span><span class="p">))</span> +</span><span id="BigQuery.Parser-703"><a href="#BigQuery.Parser-703"><span class="linenos">703</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">table_parts</span><span class="p">,</span> <span class="o">-</span><span class="mi">4</span><span class="p">))</span> +</span><span id="BigQuery.Parser-704"><a href="#BigQuery.Parser-704"><span class="linenos">704</span></a> +</span><span id="BigQuery.Parser-705"><a href="#BigQuery.Parser-705"><span class="linenos">705</span></a> <span class="k">return</span> <span class="n">table</span> +</span><span id="BigQuery.Parser-706"><a href="#BigQuery.Parser-706"><span class="linenos">706</span></a> +</span><span id="BigQuery.Parser-707"><a href="#BigQuery.Parser-707"><span class="linenos">707</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="BigQuery.Parser-708"><a href="#BigQuery.Parser-708"><span class="linenos">708</span></a> <span class="n">column</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="BigQuery.Parser-709"><a href="#BigQuery.Parser-709"><span class="linenos">709</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="BigQuery.Parser-710"><a href="#BigQuery.Parser-710"><span class="linenos">710</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span> +</span><span id="BigQuery.Parser-711"><a href="#BigQuery.Parser-711"><span class="linenos">711</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="s2">"."</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">):</span> +</span><span id="BigQuery.Parser-712"><a href="#BigQuery.Parser-712"><span class="linenos">712</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="BigQuery.Parser-713"><a href="#BigQuery.Parser-713"><span class="linenos">713</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">p</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="BigQuery.Parser-714"><a href="#BigQuery.Parser-714"><span class="linenos">714</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">split_num_words</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">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">parts</span><span class="p">),</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> +</span><span id="BigQuery.Parser-715"><a href="#BigQuery.Parser-715"><span class="linenos">715</span></a> <span class="p">)</span> +</span><span id="BigQuery.Parser-716"><a href="#BigQuery.Parser-716"><span class="linenos">716</span></a> +</span><span id="BigQuery.Parser-717"><a href="#BigQuery.Parser-717"><span class="linenos">717</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> +</span><span id="BigQuery.Parser-718"><a href="#BigQuery.Parser-718"><span class="linenos">718</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">([</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">])</span> <span class="c1"># type: ignore</span> +</span><span id="BigQuery.Parser-719"><a href="#BigQuery.Parser-719"><span class="linenos">719</span></a> +</span><span id="BigQuery.Parser-720"><a href="#BigQuery.Parser-720"><span class="linenos">720</span></a> <span class="n">column</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">table</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><span id="BigQuery.Parser-721"><a href="#BigQuery.Parser-721"><span class="linenos">721</span></a> <span class="n">column</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"quoted_column"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Parser-722"><a href="#BigQuery.Parser-722"><span class="linenos">722</span></a> +</span><span id="BigQuery.Parser-723"><a href="#BigQuery.Parser-723"><span class="linenos">723</span></a> <span class="k">return</span> <span class="n">column</span> +</span><span id="BigQuery.Parser-724"><a href="#BigQuery.Parser-724"><span class="linenos">724</span></a> +</span><span id="BigQuery.Parser-725"><a href="#BigQuery.Parser-725"><span class="linenos">725</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="BigQuery.Parser-726"><a href="#BigQuery.Parser-726"><span class="linenos">726</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObject</span><span class="p">:</span> <span class="o">...</span> +</span><span id="BigQuery.Parser-727"><a href="#BigQuery.Parser-727"><span class="linenos">727</span></a> +</span><span id="BigQuery.Parser-728"><a href="#BigQuery.Parser-728"><span class="linenos">728</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="BigQuery.Parser-729"><a href="#BigQuery.Parser-729"><span class="linenos">729</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="n">agg</span><span class="p">:</span> <span class="n">Lit</span><span class="p">[</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">JSONObjectAgg</span><span class="p">:</span> <span class="o">...</span> </span><span id="BigQuery.Parser-730"><a href="#BigQuery.Parser-730"><span class="linenos">730</span></a> -</span><span id="BigQuery.Parser-731"><a href="#BigQuery.Parser-731"><span class="linenos">731</span></a> <span class="c1"># Converts BQ's "signature 2" of JSON_OBJECT into SQLGlot's canonical representation</span> -</span><span id="BigQuery.Parser-732"><a href="#BigQuery.Parser-732"><span class="linenos">732</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#json_object_signature2</span> -</span><span id="BigQuery.Parser-733"><a href="#BigQuery.Parser-733"><span class="linenos">733</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="BigQuery.Parser-734"><a href="#BigQuery.Parser-734"><span class="linenos">734</span></a> <span class="n">array_kv_pair</span> -</span><span id="BigQuery.Parser-735"><a href="#BigQuery.Parser-735"><span class="linenos">735</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> -</span><span id="BigQuery.Parser-736"><a href="#BigQuery.Parser-736"><span class="linenos">736</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span 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><span id="BigQuery.Parser-737"><a href="#BigQuery.Parser-737"><span class="linenos">737</span></a> <span class="p">):</span> -</span><span id="BigQuery.Parser-738"><a href="#BigQuery.Parser-738"><span class="linenos">738</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="BigQuery.Parser-739"><a href="#BigQuery.Parser-739"><span class="linenos">739</span></a> <span class="n">values</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="BigQuery.Parser-740"><a href="#BigQuery.Parser-740"><span class="linenos">740</span></a> -</span><span id="BigQuery.Parser-741"><a href="#BigQuery.Parser-741"><span class="linenos">741</span></a> <span class="n">json_object</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="BigQuery.Parser-742"><a href="#BigQuery.Parser-742"><span class="linenos">742</span></a> <span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="BigQuery.Parser-743"><a href="#BigQuery.Parser-743"><span class="linenos">743</span></a> <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">k</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">values</span><span class="p">)],</span> -</span><span id="BigQuery.Parser-744"><a href="#BigQuery.Parser-744"><span class="linenos">744</span></a> <span class="p">)</span> -</span><span id="BigQuery.Parser-745"><a href="#BigQuery.Parser-745"><span class="linenos">745</span></a> -</span><span id="BigQuery.Parser-746"><a href="#BigQuery.Parser-746"><span class="linenos">746</span></a> <span class="k">return</span> <span class="n">json_object</span> -</span><span id="BigQuery.Parser-747"><a href="#BigQuery.Parser-747"><span class="linenos">747</span></a> -</span><span id="BigQuery.Parser-748"><a href="#BigQuery.Parser-748"><span class="linenos">748</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> -</span><span id="BigQuery.Parser-749"><a href="#BigQuery.Parser-749"><span class="linenos">749</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="BigQuery.Parser-750"><a href="#BigQuery.Parser-750"><span class="linenos">750</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="BigQuery.Parser-751"><a href="#BigQuery.Parser-751"><span class="linenos">751</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="BigQuery.Parser-752"><a href="#BigQuery.Parser-752"><span class="linenos">752</span></a> -</span><span id="BigQuery.Parser-753"><a href="#BigQuery.Parser-753"><span class="linenos">753</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">is</span> <span class="n">bracket</span><span class="p">:</span> -</span><span id="BigQuery.Parser-754"><a href="#BigQuery.Parser-754"><span class="linenos">754</span></a> <span class="k">return</span> <span class="n">bracket</span> -</span><span id="BigQuery.Parser-755"><a href="#BigQuery.Parser-755"><span class="linenos">755</span></a> -</span><span id="BigQuery.Parser-756"><a href="#BigQuery.Parser-756"><span class="linenos">756</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> -</span><span id="BigQuery.Parser-757"><a href="#BigQuery.Parser-757"><span class="linenos">757</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">bracket</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="BigQuery.Parser-758"><a href="#BigQuery.Parser-758"><span class="linenos">758</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="BigQuery.Parser-731"><a href="#BigQuery.Parser-731"><span class="linenos">731</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="n">agg</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> +</span><span id="BigQuery.Parser-732"><a href="#BigQuery.Parser-732"><span class="linenos">732</span></a> <span class="n">json_object</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_json_object</span><span class="p">()</span> +</span><span id="BigQuery.Parser-733"><a href="#BigQuery.Parser-733"><span class="linenos">733</span></a> <span class="n">array_kv_pair</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">json_object</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="BigQuery.Parser-734"><a href="#BigQuery.Parser-734"><span class="linenos">734</span></a> +</span><span id="BigQuery.Parser-735"><a href="#BigQuery.Parser-735"><span class="linenos">735</span></a> <span class="c1"># Converts BQ's "signature 2" of JSON_OBJECT into SQLGlot's canonical representation</span> +</span><span id="BigQuery.Parser-736"><a href="#BigQuery.Parser-736"><span class="linenos">736</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#json_object_signature2</span> +</span><span id="BigQuery.Parser-737"><a href="#BigQuery.Parser-737"><span class="linenos">737</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="BigQuery.Parser-738"><a href="#BigQuery.Parser-738"><span class="linenos">738</span></a> <span class="n">array_kv_pair</span> +</span><span id="BigQuery.Parser-739"><a href="#BigQuery.Parser-739"><span class="linenos">739</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> +</span><span id="BigQuery.Parser-740"><a href="#BigQuery.Parser-740"><span class="linenos">740</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">array_kv_pair</span><span 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><span id="BigQuery.Parser-741"><a href="#BigQuery.Parser-741"><span class="linenos">741</span></a> <span class="p">):</span> +</span><span id="BigQuery.Parser-742"><a href="#BigQuery.Parser-742"><span class="linenos">742</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery.Parser-743"><a href="#BigQuery.Parser-743"><span class="linenos">743</span></a> <span class="n">values</span> <span class="o">=</span> <span class="n">array_kv_pair</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery.Parser-744"><a href="#BigQuery.Parser-744"><span class="linenos">744</span></a> +</span><span id="BigQuery.Parser-745"><a href="#BigQuery.Parser-745"><span class="linenos">745</span></a> <span class="n">json_object</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="BigQuery.Parser-746"><a href="#BigQuery.Parser-746"><span class="linenos">746</span></a> <span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="BigQuery.Parser-747"><a href="#BigQuery.Parser-747"><span class="linenos">747</span></a> <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">k</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">values</span><span class="p">)],</span> +</span><span id="BigQuery.Parser-748"><a href="#BigQuery.Parser-748"><span class="linenos">748</span></a> <span class="p">)</span> +</span><span id="BigQuery.Parser-749"><a href="#BigQuery.Parser-749"><span class="linenos">749</span></a> +</span><span id="BigQuery.Parser-750"><a href="#BigQuery.Parser-750"><span class="linenos">750</span></a> <span class="k">return</span> <span class="n">json_object</span> +</span><span id="BigQuery.Parser-751"><a href="#BigQuery.Parser-751"><span class="linenos">751</span></a> +</span><span id="BigQuery.Parser-752"><a href="#BigQuery.Parser-752"><span class="linenos">752</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> +</span><span id="BigQuery.Parser-753"><a href="#BigQuery.Parser-753"><span class="linenos">753</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="BigQuery.Parser-754"><a href="#BigQuery.Parser-754"><span class="linenos">754</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="BigQuery.Parser-755"><a href="#BigQuery.Parser-755"><span class="linenos">755</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="BigQuery.Parser-756"><a href="#BigQuery.Parser-756"><span class="linenos">756</span></a> +</span><span id="BigQuery.Parser-757"><a href="#BigQuery.Parser-757"><span class="linenos">757</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">is</span> <span class="n">bracket</span><span class="p">:</span> +</span><span id="BigQuery.Parser-758"><a href="#BigQuery.Parser-758"><span class="linenos">758</span></a> <span class="k">return</span> <span class="n">bracket</span> </span><span id="BigQuery.Parser-759"><a href="#BigQuery.Parser-759"><span class="linenos">759</span></a> -</span><span id="BigQuery.Parser-760"><a href="#BigQuery.Parser-760"><span class="linenos">760</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">:</span> -</span><span id="BigQuery.Parser-761"><a href="#BigQuery.Parser-761"><span class="linenos">761</span></a> <span class="k">break</span> -</span><span id="BigQuery.Parser-762"><a href="#BigQuery.Parser-762"><span class="linenos">762</span></a> -</span><span id="BigQuery.Parser-763"><a href="#BigQuery.Parser-763"><span class="linenos">763</span></a> <span class="n">offset</span><span class="p">,</span> <span class="n">safe</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> -</span><span id="BigQuery.Parser-764"><a href="#BigQuery.Parser-764"><span class="linenos">764</span></a> <span class="n">bracket</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">offset</span><span class="p">)</span> -</span><span id="BigQuery.Parser-765"><a href="#BigQuery.Parser-765"><span class="linenos">765</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">,</span> <span class="n">safe</span><span class="p">)</span> -</span><span id="BigQuery.Parser-766"><a href="#BigQuery.Parser-766"><span class="linenos">766</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> -</span><span id="BigQuery.Parser-767"><a href="#BigQuery.Parser-767"><span class="linenos">767</span></a> -</span><span id="BigQuery.Parser-768"><a href="#BigQuery.Parser-768"><span class="linenos">768</span></a> <span class="k">return</span> <span class="n">bracket</span> -</span><span id="BigQuery.Parser-769"><a href="#BigQuery.Parser-769"><span class="linenos">769</span></a> -</span><span id="BigQuery.Parser-770"><a href="#BigQuery.Parser-770"><span class="linenos">770</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="BigQuery.Parser-771"><a href="#BigQuery.Parser-771"><span class="linenos">771</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</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="n">with_alias</span><span class="p">)</span> -</span><span id="BigQuery.Parser-772"><a href="#BigQuery.Parser-772"><span class="linenos">772</span></a> -</span><span id="BigQuery.Parser-773"><a href="#BigQuery.Parser-773"><span class="linenos">773</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="BigQuery.Parser-774"><a href="#BigQuery.Parser-774"><span class="linenos">774</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="BigQuery.Parser-775"><a href="#BigQuery.Parser-775"><span class="linenos">775</span></a> -</span><span id="BigQuery.Parser-776"><a href="#BigQuery.Parser-776"><span class="linenos">776</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">unnest</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="BigQuery.Parser-777"><a href="#BigQuery.Parser-777"><span class="linenos">777</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="p">:</span> -</span><span id="BigQuery.Parser-778"><a href="#BigQuery.Parser-778"><span class="linenos">778</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="BigQuery.Parser-760"><a href="#BigQuery.Parser-760"><span class="linenos">760</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> +</span><span id="BigQuery.Parser-761"><a href="#BigQuery.Parser-761"><span class="linenos">761</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">bracket</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="BigQuery.Parser-762"><a href="#BigQuery.Parser-762"><span class="linenos">762</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="BigQuery.Parser-763"><a href="#BigQuery.Parser-763"><span class="linenos">763</span></a> +</span><span id="BigQuery.Parser-764"><a href="#BigQuery.Parser-764"><span class="linenos">764</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">:</span> +</span><span id="BigQuery.Parser-765"><a href="#BigQuery.Parser-765"><span class="linenos">765</span></a> <span class="k">break</span> +</span><span id="BigQuery.Parser-766"><a href="#BigQuery.Parser-766"><span class="linenos">766</span></a> +</span><span id="BigQuery.Parser-767"><a href="#BigQuery.Parser-767"><span class="linenos">767</span></a> <span class="n">offset</span><span class="p">,</span> <span class="n">safe</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">BRACKET_OFFSETS</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> +</span><span id="BigQuery.Parser-768"><a href="#BigQuery.Parser-768"><span class="linenos">768</span></a> <span class="n">bracket</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">offset</span><span class="p">)</span> +</span><span id="BigQuery.Parser-769"><a href="#BigQuery.Parser-769"><span class="linenos">769</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">,</span> <span class="n">safe</span><span class="p">)</span> +</span><span id="BigQuery.Parser-770"><a href="#BigQuery.Parser-770"><span class="linenos">770</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="BigQuery.Parser-771"><a href="#BigQuery.Parser-771"><span class="linenos">771</span></a> +</span><span id="BigQuery.Parser-772"><a href="#BigQuery.Parser-772"><span class="linenos">772</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="BigQuery.Parser-773"><a href="#BigQuery.Parser-773"><span class="linenos">773</span></a> +</span><span id="BigQuery.Parser-774"><a href="#BigQuery.Parser-774"><span class="linenos">774</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="BigQuery.Parser-775"><a href="#BigQuery.Parser-775"><span class="linenos">775</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</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="n">with_alias</span><span class="p">)</span> +</span><span id="BigQuery.Parser-776"><a href="#BigQuery.Parser-776"><span class="linenos">776</span></a> +</span><span id="BigQuery.Parser-777"><a href="#BigQuery.Parser-777"><span class="linenos">777</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="BigQuery.Parser-778"><a href="#BigQuery.Parser-778"><span class="linenos">778</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="BigQuery.Parser-779"><a href="#BigQuery.Parser-779"><span class="linenos">779</span></a> -</span><span id="BigQuery.Parser-780"><a href="#BigQuery.Parser-780"><span class="linenos">780</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">unnest_expr</span><span class="p">)</span> -</span><span id="BigQuery.Parser-781"><a href="#BigQuery.Parser-781"><span class="linenos">781</span></a> -</span><span id="BigQuery.Parser-782"><a href="#BigQuery.Parser-782"><span class="linenos">782</span></a> <span class="c1"># Unnesting a nested array (i.e array of structs) explodes the top-level struct fields,</span> -</span><span id="BigQuery.Parser-783"><a href="#BigQuery.Parser-783"><span class="linenos">783</span></a> <span class="c1"># in contrast to other dialects such as DuckDB which flattens only the array by default</span> -</span><span id="BigQuery.Parser-784"><a href="#BigQuery.Parser-784"><span class="linenos">784</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span> -</span><span id="BigQuery.Parser-785"><a href="#BigQuery.Parser-785"><span class="linenos">785</span></a> <span class="n">array_elem</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">)</span> -</span><span id="BigQuery.Parser-786"><a href="#BigQuery.Parser-786"><span class="linenos">786</span></a> <span class="k">for</span> <span class="n">array_elem</span> <span class="ow">in</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">_type</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="BigQuery.Parser-787"><a href="#BigQuery.Parser-787"><span class="linenos">787</span></a> <span class="p">):</span> -</span><span id="BigQuery.Parser-788"><a href="#BigQuery.Parser-788"><span class="linenos">788</span></a> <span class="n">unnest</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"explode_array"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> -</span><span id="BigQuery.Parser-789"><a href="#BigQuery.Parser-789"><span class="linenos">789</span></a> -</span><span id="BigQuery.Parser-790"><a href="#BigQuery.Parser-790"><span class="linenos">790</span></a> <span class="k">return</span> <span class="n">unnest</span> -</span><span id="BigQuery.Parser-791"><a href="#BigQuery.Parser-791"><span class="linenos">791</span></a> -</span><span id="BigQuery.Parser-792"><a href="#BigQuery.Parser-792"><span class="linenos">792</span></a> <span class="k">def</span> <span class="nf">_parse_make_interval</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">:</span> -</span><span id="BigQuery.Parser-793"><a href="#BigQuery.Parser-793"><span class="linenos">793</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">()</span> -</span><span id="BigQuery.Parser-794"><a href="#BigQuery.Parser-794"><span class="linenos">794</span></a> -</span><span id="BigQuery.Parser-795"><a href="#BigQuery.Parser-795"><span class="linenos">795</span></a> <span class="k">for</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="n">expr</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> -</span><span id="BigQuery.Parser-796"><a href="#BigQuery.Parser-796"><span class="linenos">796</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> -</span><span id="BigQuery.Parser-797"><a href="#BigQuery.Parser-797"><span class="linenos">797</span></a> -</span><span id="BigQuery.Parser-798"><a href="#BigQuery.Parser-798"><span class="linenos">798</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> -</span><span id="BigQuery.Parser-799"><a href="#BigQuery.Parser-799"><span class="linenos">799</span></a> <span class="k">break</span> -</span><span id="BigQuery.Parser-800"><a href="#BigQuery.Parser-800"><span class="linenos">800</span></a> -</span><span id="BigQuery.Parser-801"><a href="#BigQuery.Parser-801"><span class="linenos">801</span></a> <span class="c1"># Non-named arguments are filled sequentially, (optionally) followed by named arguments</span> -</span><span id="BigQuery.Parser-802"><a href="#BigQuery.Parser-802"><span class="linenos">802</span></a> <span class="c1"># that can appear in any order e.g MAKE_INTERVAL(1, minute => 5, day => 2)</span> -</span><span id="BigQuery.Parser-803"><a href="#BigQuery.Parser-803"><span class="linenos">803</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">):</span> -</span><span id="BigQuery.Parser-804"><a href="#BigQuery.Parser-804"><span class="linenos">804</span></a> <span class="n">arg_key</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="BigQuery.Parser-805"><a href="#BigQuery.Parser-805"><span class="linenos">805</span></a> -</span><span id="BigQuery.Parser-806"><a href="#BigQuery.Parser-806"><span class="linenos">806</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg_key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> -</span><span id="BigQuery.Parser-807"><a href="#BigQuery.Parser-807"><span class="linenos">807</span></a> -</span><span id="BigQuery.Parser-808"><a href="#BigQuery.Parser-808"><span class="linenos">808</span></a> <span class="bp">self</span><span 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="BigQuery.Parser-780"><a href="#BigQuery.Parser-780"><span class="linenos">780</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">unnest</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="BigQuery.Parser-781"><a href="#BigQuery.Parser-781"><span class="linenos">781</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="p">:</span> +</span><span id="BigQuery.Parser-782"><a href="#BigQuery.Parser-782"><span class="linenos">782</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="BigQuery.Parser-783"><a href="#BigQuery.Parser-783"><span class="linenos">783</span></a> +</span><span id="BigQuery.Parser-784"><a href="#BigQuery.Parser-784"><span class="linenos">784</span></a> <span class="n">unnest_expr</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">unnest_expr</span><span class="p">)</span> +</span><span id="BigQuery.Parser-785"><a href="#BigQuery.Parser-785"><span class="linenos">785</span></a> +</span><span id="BigQuery.Parser-786"><a href="#BigQuery.Parser-786"><span class="linenos">786</span></a> <span class="c1"># Unnesting a nested array (i.e array of structs) explodes the top-level struct fields,</span> +</span><span id="BigQuery.Parser-787"><a href="#BigQuery.Parser-787"><span class="linenos">787</span></a> <span class="c1"># in contrast to other dialects such as DuckDB which flattens only the array by default</span> +</span><span id="BigQuery.Parser-788"><a href="#BigQuery.Parser-788"><span class="linenos">788</span></a> <span class="k">if</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span> +</span><span id="BigQuery.Parser-789"><a href="#BigQuery.Parser-789"><span class="linenos">789</span></a> <span class="n">array_elem</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">)</span> +</span><span id="BigQuery.Parser-790"><a href="#BigQuery.Parser-790"><span class="linenos">790</span></a> <span class="k">for</span> <span class="n">array_elem</span> <span class="ow">in</span> <span class="n">unnest_expr</span><span class="o">.</span><span class="n">_type</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery.Parser-791"><a href="#BigQuery.Parser-791"><span class="linenos">791</span></a> <span class="p">):</span> +</span><span id="BigQuery.Parser-792"><a href="#BigQuery.Parser-792"><span class="linenos">792</span></a> <span class="n">unnest</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"explode_array"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> +</span><span id="BigQuery.Parser-793"><a href="#BigQuery.Parser-793"><span class="linenos">793</span></a> +</span><span id="BigQuery.Parser-794"><a href="#BigQuery.Parser-794"><span class="linenos">794</span></a> <span class="k">return</span> <span class="n">unnest</span> +</span><span id="BigQuery.Parser-795"><a href="#BigQuery.Parser-795"><span class="linenos">795</span></a> +</span><span id="BigQuery.Parser-796"><a href="#BigQuery.Parser-796"><span class="linenos">796</span></a> <span class="k">def</span> <span class="nf">_parse_make_interval</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">:</span> +</span><span id="BigQuery.Parser-797"><a href="#BigQuery.Parser-797"><span class="linenos">797</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">MakeInterval</span><span class="p">()</span> +</span><span id="BigQuery.Parser-798"><a href="#BigQuery.Parser-798"><span class="linenos">798</span></a> +</span><span id="BigQuery.Parser-799"><a href="#BigQuery.Parser-799"><span class="linenos">799</span></a> <span class="k">for</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="n">expr</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> +</span><span id="BigQuery.Parser-800"><a href="#BigQuery.Parser-800"><span class="linenos">800</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> +</span><span id="BigQuery.Parser-801"><a href="#BigQuery.Parser-801"><span class="linenos">801</span></a> +</span><span id="BigQuery.Parser-802"><a href="#BigQuery.Parser-802"><span class="linenos">802</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> +</span><span id="BigQuery.Parser-803"><a href="#BigQuery.Parser-803"><span class="linenos">803</span></a> <span class="k">break</span> +</span><span id="BigQuery.Parser-804"><a href="#BigQuery.Parser-804"><span class="linenos">804</span></a> +</span><span id="BigQuery.Parser-805"><a href="#BigQuery.Parser-805"><span class="linenos">805</span></a> <span class="c1"># Non-named arguments are filled sequentially, (optionally) followed by named arguments</span> +</span><span id="BigQuery.Parser-806"><a href="#BigQuery.Parser-806"><span class="linenos">806</span></a> <span class="c1"># that can appear in any order e.g MAKE_INTERVAL(1, minute => 5, day => 2)</span> +</span><span id="BigQuery.Parser-807"><a href="#BigQuery.Parser-807"><span class="linenos">807</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">):</span> +</span><span id="BigQuery.Parser-808"><a href="#BigQuery.Parser-808"><span class="linenos">808</span></a> <span class="n">arg_key</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> </span><span id="BigQuery.Parser-809"><a href="#BigQuery.Parser-809"><span class="linenos">809</span></a> -</span><span id="BigQuery.Parser-810"><a href="#BigQuery.Parser-810"><span class="linenos">810</span></a> <span class="k">return</span> <span class="n">expr</span> +</span><span id="BigQuery.Parser-810"><a href="#BigQuery.Parser-810"><span class="linenos">810</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg_key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> </span><span id="BigQuery.Parser-811"><a href="#BigQuery.Parser-811"><span class="linenos">811</span></a> -</span><span id="BigQuery.Parser-812"><a href="#BigQuery.Parser-812"><span class="linenos">812</span></a> <span class="k">def</span> <span class="nf">_parse_features_at_time</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">:</span> -</span><span id="BigQuery.Parser-813"><a href="#BigQuery.Parser-813"><span class="linenos">813</span></a> <span class="n">expr</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="BigQuery.Parser-814"><a href="#BigQuery.Parser-814"><span class="linenos">814</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">,</span> -</span><span id="BigQuery.Parser-815"><a href="#BigQuery.Parser-815"><span class="linenos">815</span></a> <span class="n">this</span><span class="o">=</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">TABLE</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="BigQuery.Parser-816"><a href="#BigQuery.Parser-816"><span class="linenos">816</span></a> <span class="ow">or</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="BigQuery.Parser-817"><a href="#BigQuery.Parser-817"><span class="linenos">817</span></a> <span class="p">)</span> -</span><span id="BigQuery.Parser-818"><a href="#BigQuery.Parser-818"><span class="linenos">818</span></a> -</span><span id="BigQuery.Parser-819"><a href="#BigQuery.Parser-819"><span class="linenos">819</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">COMMA</span><span class="p">):</span> -</span><span id="BigQuery.Parser-820"><a href="#BigQuery.Parser-820"><span class="linenos">820</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> -</span><span id="BigQuery.Parser-821"><a href="#BigQuery.Parser-821"><span class="linenos">821</span></a> -</span><span id="BigQuery.Parser-822"><a href="#BigQuery.Parser-822"><span class="linenos">822</span></a> <span class="c1"># Get the LHS of the Kwarg and set the arg to that value, e.g</span> -</span><span id="BigQuery.Parser-823"><a href="#BigQuery.Parser-823"><span class="linenos">823</span></a> <span class="c1"># "num_rows => 1" sets the expr's `num_rows` arg</span> -</span><span id="BigQuery.Parser-824"><a href="#BigQuery.Parser-824"><span class="linenos">824</span></a> <span class="k">if</span> <span class="n">arg</span><span class="p">:</span> -</span><span id="BigQuery.Parser-825"><a href="#BigQuery.Parser-825"><span class="linenos">825</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> -</span><span id="BigQuery.Parser-826"><a href="#BigQuery.Parser-826"><span class="linenos">826</span></a> -</span><span id="BigQuery.Parser-827"><a href="#BigQuery.Parser-827"><span class="linenos">827</span></a> <span class="k">return</span> <span class="n">expr</span> +</span><span id="BigQuery.Parser-812"><a href="#BigQuery.Parser-812"><span class="linenos">812</span></a> <span class="bp">self</span><span 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="BigQuery.Parser-813"><a href="#BigQuery.Parser-813"><span class="linenos">813</span></a> +</span><span id="BigQuery.Parser-814"><a href="#BigQuery.Parser-814"><span class="linenos">814</span></a> <span class="k">return</span> <span class="n">expr</span> +</span><span id="BigQuery.Parser-815"><a href="#BigQuery.Parser-815"><span class="linenos">815</span></a> +</span><span id="BigQuery.Parser-816"><a href="#BigQuery.Parser-816"><span class="linenos">816</span></a> <span class="k">def</span> <span class="nf">_parse_features_at_time</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">:</span> +</span><span id="BigQuery.Parser-817"><a href="#BigQuery.Parser-817"><span class="linenos">817</span></a> <span class="n">expr</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="BigQuery.Parser-818"><a href="#BigQuery.Parser-818"><span class="linenos">818</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FeaturesAtTime</span><span class="p">,</span> +</span><span id="BigQuery.Parser-819"><a href="#BigQuery.Parser-819"><span class="linenos">819</span></a> <span class="n">this</span><span class="o">=</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">TABLE</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="BigQuery.Parser-820"><a href="#BigQuery.Parser-820"><span class="linenos">820</span></a> <span class="ow">or</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="BigQuery.Parser-821"><a href="#BigQuery.Parser-821"><span class="linenos">821</span></a> <span class="p">)</span> +</span><span id="BigQuery.Parser-822"><a href="#BigQuery.Parser-822"><span class="linenos">822</span></a> +</span><span id="BigQuery.Parser-823"><a href="#BigQuery.Parser-823"><span class="linenos">823</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">COMMA</span><span class="p">):</span> +</span><span id="BigQuery.Parser-824"><a href="#BigQuery.Parser-824"><span class="linenos">824</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">()</span> +</span><span id="BigQuery.Parser-825"><a href="#BigQuery.Parser-825"><span class="linenos">825</span></a> +</span><span id="BigQuery.Parser-826"><a href="#BigQuery.Parser-826"><span class="linenos">826</span></a> <span class="c1"># Get the LHS of the Kwarg and set the arg to that value, e.g</span> +</span><span id="BigQuery.Parser-827"><a href="#BigQuery.Parser-827"><span class="linenos">827</span></a> <span class="c1"># "num_rows => 1" sets the expr's `num_rows` arg</span> +</span><span id="BigQuery.Parser-828"><a href="#BigQuery.Parser-828"><span class="linenos">828</span></a> <span class="k">if</span> <span class="n">arg</span><span class="p">:</span> +</span><span id="BigQuery.Parser-829"><a href="#BigQuery.Parser-829"><span class="linenos">829</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="BigQuery.Parser-830"><a href="#BigQuery.Parser-830"><span class="linenos">830</span></a> +</span><span id="BigQuery.Parser-831"><a href="#BigQuery.Parser-831"><span class="linenos">831</span></a> <span class="k">return</span> <span class="n">expr</span> </span></pre></div> @@ -3908,7 +3923,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">NESTED_TYPE_TOKENS</span> = <input id="BigQuery.Parser.NESTED_TYPE_TOKENS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="BigQuery.Parser.NESTED_TYPE_TOKENS-view-value"></label><span class="default_value">{<TokenType.OBJECT: 'OBJECT'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.RANGE: 'RANGE'>, <TokenType.LIST: 'LIST'>, <TokenType.UNION: 'UNION'>, <TokenType.TABLE: 'TABLE'>, <TokenType.NESTED: 'NESTED'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.MAP: 'MAP'>}</span> + <label class="view-value-button pdoc-button" for="BigQuery.Parser.NESTED_TYPE_TOKENS-view-value"></label><span class="default_value">{<TokenType.NULLABLE: 'NULLABLE'>, <TokenType.NESTED: 'NESTED'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.MAP: 'MAP'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.RANGE: 'RANGE'>, <TokenType.UNION: 'UNION'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.TABLE: 'TABLE'>, <TokenType.LIST: 'LIST'>}</span> </div> @@ -3959,7 +3974,7 @@ Default: 3</li> <div id="BigQuery.Parser.NULL_TOKENS" class="classattr"> <div class="attr variable"> <span class="name">NULL_TOKENS</span> = -<span class="default_value">{<TokenType.NULL: 'NULL'>, <TokenType.UNKNOWN: 'UNKNOWN'>}</span> +<span class="default_value">{<TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.NULL: 'NULL'>}</span> </div> @@ -3968,6 +3983,18 @@ Default: 3</li> </div> + <div id="BigQuery.Parser.DASHED_TABLE_PART_FOLLOW_TOKENS" class="classattr"> + <div class="attr variable"> + <span class="name">DASHED_TABLE_PART_FOLLOW_TOKENS</span> = +<span class="default_value">{<TokenType.R_PAREN: 'R_PAREN'>, <TokenType.L_PAREN: 'L_PAREN'>, <TokenType.DOT: 'DOT'>}</span> + + + </div> + <a class="headerlink" href="#BigQuery.Parser.DASHED_TABLE_PART_FOLLOW_TOKENS"></a> + + + + </div> <div id="BigQuery.Parser.STATEMENT_PARSERS" class="classattr"> <div class="attr variable"> <span class="name">STATEMENT_PARSERS</span> = @@ -3997,7 +4024,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">ID_VAR_TOKENS</span> = <input id="BigQuery.Parser.ID_VAR_TOKENS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="BigQuery.Parser.ID_VAR_TOKENS-view-value"></label><span class="default_value">{<TokenType.POINT: 'POINT'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.VAR: 'VAR'>, <TokenType.KEEP: 'KEEP'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.CHAR: 'CHAR'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.ROW: 'ROW'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.FINAL: 'FINAL'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.NAME: 'NAME'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.KILL: 'KILL'>, <TokenType.RENAME: 'RENAME'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.SHOW: 'SHOW'>, <TokenType.FALSE: 'FALSE'>, <TokenType.UINT128: 'UINT128'>, <TokenType.SINK: 'SINK'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.IPV6: 'IPV6'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.FILTER: 'FILTER'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.ROWS: 'ROWS'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.BIT: 'BIT'>, <TokenType.SUPER: 'SUPER'>, <TokenType.TOP: 'TOP'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.MODEL: 'MODEL'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.RING: 'RING'>, <TokenType.ASOF: 'ASOF'>, <TokenType.IS: 'IS'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.LEFT: 'LEFT'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.INT256: 'INT256'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.SEMI: 'SEMI'>, <TokenType.SET: 'SET'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.BINARY: 'BINARY'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TIME: 'TIME'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.CASE: 'CASE'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.DELETE: 'DELETE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.INET: 'INET'>, <TokenType.NESTED: 'NESTED'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.YEAR: 'YEAR'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.INDEX: 'INDEX'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.DATE32: 'DATE32'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.MERGE: 'MERGE'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.IPV4: 'IPV4'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.APPLY: 'APPLY'>, <TokenType.XML: 'XML'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.COPY: 'COPY'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.UUID: 'UUID'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.CUBE: 'CUBE'>, <TokenType.DETACH: 'DETACH'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.INT: 'INT'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.TRUE: 'TRUE'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.ANTI: 'ANTI'>, <TokenType.ANY: 'ANY'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.MAP: 'MAP'>, <TokenType.ASC: 'ASC'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.ALL: 'ALL'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.END: 'END'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.DATE: 'DATE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.RANGE: 'RANGE'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.NULL: 'NULL'>, <TokenType.DIV: 'DIV'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.TABLE: 'TABLE'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.SOME: 'SOME'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.NEXT: 'NEXT'>, <TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.FIRST: 'FIRST'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.UINT256: 'UINT256'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.JSONB: 'JSONB'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.INT128: 'INT128'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.JSON: 'JSON'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.FULL: 'FULL'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.UINT: 'UINT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.DESC: 'DESC'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.TAG: 'TAG'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.LIST: 'LIST'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.TEXT: 'TEXT'>, <TokenType.USE: 'USE'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>}</span> + <label class="view-value-button pdoc-button" for="BigQuery.Parser.ID_VAR_TOKENS-view-value"></label><span class="default_value">{<TokenType.UPDATE: 'UPDATE'>, <TokenType.TIME: 'TIME'>, <TokenType.SUPER: 'SUPER'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.ANY: 'ANY'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.MERGE: 'MERGE'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.INT256: 'INT256'>, <TokenType.MONEY: 'MONEY'>, <TokenType.CACHE: 'CACHE'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.VIEW: 'VIEW'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.DETACH: 'DETACH'>, <TokenType.TOP: 'TOP'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.SHOW: 'SHOW'>, <TokenType.SOME: 'SOME'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.ALL: 'ALL'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.BINARY: 'BINARY'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.DIV: 'DIV'>, <TokenType.DATE: 'DATE'>, <TokenType.IS: 'IS'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.IPV6: 'IPV6'>, <TokenType.VAR: 'VAR'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.LIST: 'LIST'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.CHAR: 'CHAR'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.RING: 'RING'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.UINT: 'UINT'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.TAG: 'TAG'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.IPV4: 'IPV4'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.SET: 'SET'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.END: 'END'>, <TokenType.ROW: 'ROW'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>, <TokenType.RANGE: 'RANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.DESC: 'DESC'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.UINT128: 'UINT128'>, <TokenType.TABLE: 'TABLE'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.KILL: 'KILL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.UUID: 'UUID'>, <TokenType.APPLY: 'APPLY'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.NEXT: 'NEXT'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.POINT: 'POINT'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.SINK: 'SINK'>, <TokenType.JSON: 'JSON'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.COPY: 'COPY'>, <TokenType.FIRST: 'FIRST'>, <TokenType.ANTI: 'ANTI'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.BIT: 'BIT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.FINAL: 'FINAL'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.ASC: 'ASC'>, <TokenType.INET: 'INET'>, <TokenType.DELETE: 'DELETE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.CUBE: 'CUBE'>, <TokenType.RENAME: 'RENAME'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.XML: 'XML'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.TRUE: 'TRUE'>, <TokenType.NAME: 'NAME'>, <TokenType.FALSE: 'FALSE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.SEMI: 'SEMI'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.UINT256: 'UINT256'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.ROWS: 'ROWS'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.DATE32: 'DATE32'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.ASOF: 'ASOF'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.CASE: 'CASE'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.INT: 'INT'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.MAP: 'MAP'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.INT128: 'INT128'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.JSONB: 'JSONB'>, <TokenType.KEEP: 'KEEP'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.ENUM: 'ENUM'>, <TokenType.MODEL: 'MODEL'>, <TokenType.YEAR: 'YEAR'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.LEFT: 'LEFT'>, <TokenType.USE: 'USE'>, <TokenType.FULL: 'FULL'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.NULL: 'NULL'>, <TokenType.DATETIME: 'DATETIME'>}</span> </div> @@ -4010,7 +4037,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">TABLE_ALIAS_TOKENS</span> = <input id="BigQuery.Parser.TABLE_ALIAS_TOKENS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="BigQuery.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.POINT: 'POINT'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.VAR: 'VAR'>, <TokenType.KEEP: 'KEEP'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.CHAR: 'CHAR'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.ROW: 'ROW'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.FINAL: 'FINAL'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.NAME: 'NAME'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.KILL: 'KILL'>, <TokenType.RENAME: 'RENAME'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.SHOW: 'SHOW'>, <TokenType.FALSE: 'FALSE'>, <TokenType.UINT128: 'UINT128'>, <TokenType.SINK: 'SINK'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.IPV6: 'IPV6'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.FILTER: 'FILTER'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.ROWS: 'ROWS'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.BIT: 'BIT'>, <TokenType.SUPER: 'SUPER'>, <TokenType.TOP: 'TOP'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.MODEL: 'MODEL'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.RING: 'RING'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.IS: 'IS'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.INT256: 'INT256'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.SEMI: 'SEMI'>, <TokenType.SET: 'SET'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.BINARY: 'BINARY'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TIME: 'TIME'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.CASE: 'CASE'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.DELETE: 'DELETE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.INET: 'INET'>, <TokenType.NESTED: 'NESTED'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.YEAR: 'YEAR'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.INDEX: 'INDEX'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.DATE32: 'DATE32'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.MERGE: 'MERGE'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.IPV4: 'IPV4'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.XML: 'XML'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.COPY: 'COPY'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.UUID: 'UUID'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.CUBE: 'CUBE'>, <TokenType.DETACH: 'DETACH'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.INT: 'INT'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.TRUE: 'TRUE'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.ANTI: 'ANTI'>, <TokenType.ANY: 'ANY'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.MAP: 'MAP'>, <TokenType.ASC: 'ASC'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.ALL: 'ALL'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.END: 'END'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.DATE: 'DATE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.RANGE: 'RANGE'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.NULL: 'NULL'>, <TokenType.DIV: 'DIV'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.TABLE: 'TABLE'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.SOME: 'SOME'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.NEXT: 'NEXT'>, <TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.FIRST: 'FIRST'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.UINT256: 'UINT256'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.JSONB: 'JSONB'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.INT128: 'INT128'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.JSON: 'JSON'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.UINT: 'UINT'>, <TokenType.DESC: 'DESC'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.TAG: 'TAG'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.LIST: 'LIST'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.TEXT: 'TEXT'>, <TokenType.USE: 'USE'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>}</span> + <label class="view-value-button pdoc-button" for="BigQuery.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.UPDATE: 'UPDATE'>, <TokenType.TIME: 'TIME'>, <TokenType.SUPER: 'SUPER'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.ANY: 'ANY'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.MERGE: 'MERGE'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.INT256: 'INT256'>, <TokenType.MONEY: 'MONEY'>, <TokenType.CACHE: 'CACHE'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.VIEW: 'VIEW'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.DETACH: 'DETACH'>, <TokenType.TOP: 'TOP'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.SHOW: 'SHOW'>, <TokenType.SOME: 'SOME'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.ALL: 'ALL'>, <TokenType.BINARY: 'BINARY'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.DIV: 'DIV'>, <TokenType.DATE: 'DATE'>, <TokenType.IS: 'IS'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.IPV6: 'IPV6'>, <TokenType.VAR: 'VAR'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.LIST: 'LIST'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.CHAR: 'CHAR'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.RING: 'RING'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.UINT: 'UINT'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.TAG: 'TAG'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.IPV4: 'IPV4'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.SET: 'SET'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.END: 'END'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.MULTILINESTRING: 'MULTILINESTRING'>, <TokenType.RANGE: 'RANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.DESC: 'DESC'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.UINT128: 'UINT128'>, <TokenType.TABLE: 'TABLE'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.KILL: 'KILL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.UUID: 'UUID'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.NEXT: 'NEXT'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.POINT: 'POINT'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.SINK: 'SINK'>, <TokenType.JSON: 'JSON'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.DECIMAL256: 'DECIMAL256'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.COPY: 'COPY'>, <TokenType.FIRST: 'FIRST'>, <TokenType.ANTI: 'ANTI'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.BIT: 'BIT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.FINAL: 'FINAL'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DECIMAL128: 'DECIMAL128'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.ASC: 'ASC'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.INET: 'INET'>, <TokenType.DELETE: 'DELETE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.CUBE: 'CUBE'>, <TokenType.RENAME: 'RENAME'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.XML: 'XML'>, <TokenType.DECIMAL32: 'DECIMAL32'>, <TokenType.POLYGON: 'POLYGON'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.MULTIPOLYGON: 'MULTIPOLYGON'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.TRUE: 'TRUE'>, <TokenType.NAME: 'NAME'>, <TokenType.FALSE: 'FALSE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.SEMI: 'SEMI'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.LINESTRING: 'LINESTRING'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.UINT256: 'UINT256'>, <TokenType.DECIMAL64: 'DECIMAL64'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.ROWS: 'ROWS'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.ATTACH: 'ATTACH'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.DATE32: 'DATE32'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.SOURCE: 'SOURCE'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.CASE: 'CASE'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.INT: 'INT'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.MAP: 'MAP'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.INT128: 'INT128'>, <TokenType.JSONB: 'JSONB'>, <TokenType.KEEP: 'KEEP'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.ENUM: 'ENUM'>, <TokenType.MODEL: 'MODEL'>, <TokenType.YEAR: 'YEAR'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.USE: 'USE'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.NULL: 'NULL'>, <TokenType.ROW: 'ROW'>}</span> </div> @@ -4184,401 +4211,401 @@ Default: 3</li> </div> <a class="headerlink" href="#BigQuery.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator-829"><a href="#BigQuery.Generator-829"><span class="linenos"> 829</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="BigQuery.Generator-830"><a href="#BigQuery.Generator-830"><span class="linenos"> 830</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-831"><a href="#BigQuery.Generator-831"><span class="linenos"> 831</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-832"><a href="#BigQuery.Generator-832"><span class="linenos"> 832</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-833"><a href="#BigQuery.Generator-833"><span class="linenos"> 833</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-834"><a href="#BigQuery.Generator-834"><span class="linenos"> 834</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="BigQuery.Generator-835"><a href="#BigQuery.Generator-835"><span class="linenos"> 835</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-836"><a href="#BigQuery.Generator-836"><span class="linenos"> 836</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-837"><a href="#BigQuery.Generator-837"><span class="linenos"> 837</span></a> <span class="n">UNNEST_WITH_ORDINALITY</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-838"><a href="#BigQuery.Generator-838"><span class="linenos"> 838</span></a> <span class="n">COLLATE_IS_FUNC</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Generator-839"><a href="#BigQuery.Generator-839"><span class="linenos"> 839</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Generator-840"><a href="#BigQuery.Generator-840"><span class="linenos"> 840</span></a> <span class="n">SUPPORTS_TABLE_ALIAS_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-841"><a href="#BigQuery.Generator-841"><span class="linenos"> 841</span></a> <span class="n">UNPIVOT_ALIASES_ARE_IDENTIFIERS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-842"><a href="#BigQuery.Generator-842"><span class="linenos"> 842</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> -</span><span id="BigQuery.Generator-843"><a href="#BigQuery.Generator-843"><span class="linenos"> 843</span></a> <span class="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-844"><a href="#BigQuery.Generator-844"><span class="linenos"> 844</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Generator-845"><a href="#BigQuery.Generator-845"><span class="linenos"> 845</span></a> <span class="n">JSON_PATH_SINGLE_QUOTE_ESCAPE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Generator-846"><a href="#BigQuery.Generator-846"><span class="linenos"> 846</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Generator-847"><a href="#BigQuery.Generator-847"><span class="linenos"> 847</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-848"><a href="#BigQuery.Generator-848"><span class="linenos"> 848</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> -</span><span id="BigQuery.Generator-849"><a href="#BigQuery.Generator-849"><span class="linenos"> 849</span></a> <span class="n">HEX_FUNC</span> <span class="o">=</span> <span class="s2">"TO_HEX"</span> -</span><span id="BigQuery.Generator-850"><a href="#BigQuery.Generator-850"><span class="linenos"> 850</span></a> <span class="n">WITH_PROPERTIES_PREFIX</span> <span class="o">=</span> <span class="s2">"OPTIONS"</span> -</span><span id="BigQuery.Generator-851"><a href="#BigQuery.Generator-851"><span class="linenos"> 851</span></a> <span class="n">SUPPORTS_EXPLODING_PROJECTIONS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-852"><a href="#BigQuery.Generator-852"><span class="linenos"> 852</span></a> <span class="n">EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-853"><a href="#BigQuery.Generator-853"><span class="linenos"> 853</span></a> <span class="n">SUPPORTS_UNIX_SECONDS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Generator-854"><a href="#BigQuery.Generator-854"><span class="linenos"> 854</span></a> -</span><span id="BigQuery.Generator-855"><a href="#BigQuery.Generator-855"><span class="linenos"> 855</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Generator-856"><a href="#BigQuery.Generator-856"><span class="linenos"> 856</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="BigQuery.Generator-857"><a href="#BigQuery.Generator-857"><span class="linenos"> 857</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-858"><a href="#BigQuery.Generator-858"><span class="linenos"> 858</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-859"><a href="#BigQuery.Generator-859"><span class="linenos"> 859</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-860"><a href="#BigQuery.Generator-860"><span class="linenos"> 860</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> -</span><span id="BigQuery.Generator-861"><a href="#BigQuery.Generator-861"><span class="linenos"> 861</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">_array_contains_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-862"><a href="#BigQuery.Generator-862"><span class="linenos"> 862</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">filter_array_using_unnest</span><span class="p">,</span> -</span><span id="BigQuery.Generator-863"><a href="#BigQuery.Generator-863"><span class="linenos"> 863</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_precision_parameterized_types</span><span class="p">]),</span> -</span><span id="BigQuery.Generator-864"><a href="#BigQuery.Generator-864"><span class="linenos"> 864</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> -</span><span id="BigQuery.Generator-865"><a href="#BigQuery.Generator-865"><span class="linenos"> 865</span></a> <span class="sa">f</span><span class="s2">"DEFAULT COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator-866"><a href="#BigQuery.Generator-866"><span class="linenos"> 866</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> -</span><span id="BigQuery.Generator-867"><a href="#BigQuery.Generator-867"><span class="linenos"> 867</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator-868"><a href="#BigQuery.Generator-868"><span class="linenos"> 868</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-869"><a href="#BigQuery.Generator-869"><span class="linenos"> 869</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"COMMIT TRANSACTION"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-870"><a href="#BigQuery.Generator-870"><span class="linenos"> 870</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COUNTIF"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-871"><a href="#BigQuery.Generator-871"><span class="linenos"> 871</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-872"><a href="#BigQuery.Generator-872"><span class="linenos"> 872</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_pushdown_cte_column_names</span><span class="p">]),</span> -</span><span id="BigQuery.Generator-873"><a href="#BigQuery.Generator-873"><span class="linenos"> 873</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-874"><a href="#BigQuery.Generator-874"><span class="linenos"> 874</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery.Generator-875"><a href="#BigQuery.Generator-875"><span class="linenos"> 875</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">unit_to_var</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="BigQuery.Generator-876"><a href="#BigQuery.Generator-876"><span class="linenos"> 876</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-877"><a href="#BigQuery.Generator-877"><span class="linenos"> 877</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-878"><a href="#BigQuery.Generator-878"><span class="linenos"> 878</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-879"><a href="#BigQuery.Generator-879"><span class="linenos"> 879</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-880"><a href="#BigQuery.Generator-880"><span class="linenos"> 880</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-881"><a href="#BigQuery.Generator-881"><span class="linenos"> 881</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-882"><a href="#BigQuery.Generator-882"><span class="linenos"> 882</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery.Generator-883"><a href="#BigQuery.Generator-883"><span class="linenos"> 883</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)</span> -</span><span id="BigQuery.Generator-884"><a href="#BigQuery.Generator-884"><span class="linenos"> 884</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-885"><a href="#BigQuery.Generator-885"><span class="linenos"> 885</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromTimeZone</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery.Generator-886"><a href="#BigQuery.Generator-886"><span class="linenos"> 886</span></a> <span class="s2">"DATETIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)),</span> <span class="s2">"'UTC'"</span> -</span><span id="BigQuery.Generator-887"><a href="#BigQuery.Generator-887"><span class="linenos"> 887</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-888"><a href="#BigQuery.Generator-888"><span class="linenos"> 888</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GENERATE_ARRAY"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-889"><a href="#BigQuery.Generator-889"><span class="linenos"> 889</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-890"><a href="#BigQuery.Generator-890"><span class="linenos"> 890</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> -</span><span id="BigQuery.Generator-891"><a href="#BigQuery.Generator-891"><span class="linenos"> 891</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(</span><span class="n">false_value</span><span class="o">=</span><span class="s2">"NULL"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-892"><a href="#BigQuery.Generator-892"><span class="linenos"> 892</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-893"><a href="#BigQuery.Generator-893"><span class="linenos"> 893</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-894"><a href="#BigQuery.Generator-894"><span class="linenos"> 894</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Int64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"INT64"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-895"><a href="#BigQuery.Generator-895"><span class="linenos"> 895</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-896"><a href="#BigQuery.Generator-896"><span class="linenos"> 896</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractArray</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-897"><a href="#BigQuery.Generator-897"><span class="linenos"> 897</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-898"><a href="#BigQuery.Generator-898"><span class="linenos"> 898</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_JSON_STRING"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-899"><a href="#BigQuery.Generator-899"><span class="linenos"> 899</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">_levenshtein_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-900"><a href="#BigQuery.Generator-900"><span class="linenos"> 900</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="BigQuery.Generator-901"><a href="#BigQuery.Generator-901"><span class="linenos"> 901</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> -</span><span id="BigQuery.Generator-902"><a href="#BigQuery.Generator-902"><span class="linenos"> 902</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-903"><a href="#BigQuery.Generator-903"><span class="linenos"> 903</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="BigQuery.Generator-904"><a href="#BigQuery.Generator-904"><span class="linenos"> 904</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-905"><a href="#BigQuery.Generator-905"><span class="linenos"> 905</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery.Generator-906"><a href="#BigQuery.Generator-906"><span class="linenos"> 906</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-907"><a href="#BigQuery.Generator-907"><span class="linenos"> 907</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="BigQuery.Generator-908"><a href="#BigQuery.Generator-908"><span class="linenos"> 908</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="BigQuery.Generator-909"><a href="#BigQuery.Generator-909"><span class="linenos"> 909</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-910"><a href="#BigQuery.Generator-910"><span class="linenos"> 910</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"occurrence"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-911"><a href="#BigQuery.Generator-911"><span class="linenos"> 911</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-912"><a href="#BigQuery.Generator-912"><span class="linenos"> 912</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtractAll</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery.Generator-913"><a href="#BigQuery.Generator-913"><span class="linenos"> 913</span></a> <span class="s2">"REGEXP_EXTRACT_ALL"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span> -</span><span id="BigQuery.Generator-914"><a href="#BigQuery.Generator-914"><span class="linenos"> 914</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-915"><a href="#BigQuery.Generator-915"><span class="linenos"> 915</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="n">regexp_replace_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-916"><a href="#BigQuery.Generator-916"><span class="linenos"> 916</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_CONTAINS"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-917"><a href="#BigQuery.Generator-917"><span class="linenos"> 917</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-918"><a href="#BigQuery.Generator-918"><span class="linenos"> 918</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"ROLLBACK TRANSACTION"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-919"><a href="#BigQuery.Generator-919"><span class="linenos"> 919</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="BigQuery.Generator-920"><a href="#BigQuery.Generator-920"><span class="linenos"> 920</span></a> <span class="p">[</span> -</span><span id="BigQuery.Generator-921"><a href="#BigQuery.Generator-921"><span class="linenos"> 921</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(),</span> -</span><span id="BigQuery.Generator-922"><a href="#BigQuery.Generator-922"><span class="linenos"> 922</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> -</span><span id="BigQuery.Generator-923"><a href="#BigQuery.Generator-923"><span class="linenos"> 923</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="BigQuery.Generator-924"><a href="#BigQuery.Generator-924"><span class="linenos"> 924</span></a> <span class="n">_alias_ordered_group</span><span class="p">,</span> -</span><span id="BigQuery.Generator-925"><a href="#BigQuery.Generator-925"><span class="linenos"> 925</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">,</span> -</span><span id="BigQuery.Generator-926"><a href="#BigQuery.Generator-926"><span class="linenos"> 926</span></a> <span class="p">]</span> -</span><span id="BigQuery.Generator-927"><a href="#BigQuery.Generator-927"><span class="linenos"> 927</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-928"><a href="#BigQuery.Generator-928"><span class="linenos"> 928</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SHA1"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-929"><a href="#BigQuery.Generator-929"><span class="linenos"> 929</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA2</span><span class="p">:</span> <span class="n">sha256_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-930"><a href="#BigQuery.Generator-930"><span class="linenos"> 930</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> -</span><span id="BigQuery.Generator-931"><a href="#BigQuery.Generator-931"><span class="linenos"> 931</span></a> <span class="s2">"DETERMINISTIC"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span> -</span><span id="BigQuery.Generator-932"><a href="#BigQuery.Generator-932"><span class="linenos"> 932</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-933"><a href="#BigQuery.Generator-933"><span class="linenos"> 933</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">String</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-934"><a href="#BigQuery.Generator-934"><span class="linenos"> 934</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-935"><a href="#BigQuery.Generator-935"><span class="linenos"> 935</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-936"><a href="#BigQuery.Generator-936"><span class="linenos"> 936</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-937"><a href="#BigQuery.Generator-937"><span class="linenos"> 937</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-938"><a href="#BigQuery.Generator-938"><span class="linenos"> 938</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-939"><a href="#BigQuery.Generator-939"><span class="linenos"> 939</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-940"><a href="#BigQuery.Generator-940"><span class="linenos"> 940</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-941"><a href="#BigQuery.Generator-941"><span class="linenos"> 941</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-942"><a href="#BigQuery.Generator-942"><span class="linenos"> 942</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP_DIFF"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-943"><a href="#BigQuery.Generator-943"><span class="linenos"> 943</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-944"><a href="#BigQuery.Generator-944"><span class="linenos"> 944</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-945"><a href="#BigQuery.Generator-945"><span class="linenos"> 945</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-946"><a href="#BigQuery.Generator-946"><span class="linenos"> 946</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-947"><a href="#BigQuery.Generator-947"><span class="linenos"> 947</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">_ts_or_ds_diff_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-948"><a href="#BigQuery.Generator-948"><span class="linenos"> 948</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-949"><a href="#BigQuery.Generator-949"><span class="linenos"> 949</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-950"><a href="#BigQuery.Generator-950"><span class="linenos"> 950</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-951"><a href="#BigQuery.Generator-951"><span class="linenos"> 951</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-952"><a href="#BigQuery.Generator-952"><span class="linenos"> 952</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_DATE"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-953"><a href="#BigQuery.Generator-953"><span class="linenos"> 953</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-954"><a href="#BigQuery.Generator-954"><span class="linenos"> 954</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uuid</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"GENERATE_UUID()"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-955"><a href="#BigQuery.Generator-955"><span class="linenos"> 955</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> -</span><span id="BigQuery.Generator-956"><a href="#BigQuery.Generator-956"><span class="linenos"> 956</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-957"><a href="#BigQuery.Generator-957"><span class="linenos"> 957</span></a> <span class="p">}</span> -</span><span id="BigQuery.Generator-958"><a href="#BigQuery.Generator-958"><span class="linenos"> 958</span></a> -</span><span id="BigQuery.Generator-959"><a href="#BigQuery.Generator-959"><span class="linenos"> 959</span></a> <span class="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Generator-960"><a href="#BigQuery.Generator-960"><span class="linenos"> 960</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> -</span><span id="BigQuery.Generator-961"><a href="#BigQuery.Generator-961"><span class="linenos"> 961</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> -</span><span id="BigQuery.Generator-962"><a href="#BigQuery.Generator-962"><span class="linenos"> 962</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> -</span><span id="BigQuery.Generator-963"><a href="#BigQuery.Generator-963"><span class="linenos"> 963</span></a> <span class="p">}</span> -</span><span id="BigQuery.Generator-964"><a href="#BigQuery.Generator-964"><span class="linenos"> 964</span></a> -</span><span id="BigQuery.Generator-965"><a href="#BigQuery.Generator-965"><span class="linenos"> 965</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Generator-966"><a href="#BigQuery.Generator-966"><span class="linenos"> 966</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="BigQuery.Generator-967"><a href="#BigQuery.Generator-967"><span class="linenos"> 967</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-968"><a href="#BigQuery.Generator-968"><span class="linenos"> 968</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-969"><a href="#BigQuery.Generator-969"><span class="linenos"> 969</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-970"><a href="#BigQuery.Generator-970"><span class="linenos"> 970</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-971"><a href="#BigQuery.Generator-971"><span class="linenos"> 971</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-972"><a href="#BigQuery.Generator-972"><span class="linenos"> 972</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">:</span> <span class="s2">"NUMERIC"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-973"><a href="#BigQuery.Generator-973"><span class="linenos"> 973</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-974"><a href="#BigQuery.Generator-974"><span class="linenos"> 974</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-975"><a href="#BigQuery.Generator-975"><span class="linenos"> 975</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-976"><a href="#BigQuery.Generator-976"><span class="linenos"> 976</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-977"><a href="#BigQuery.Generator-977"><span class="linenos"> 977</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-978"><a href="#BigQuery.Generator-978"><span class="linenos"> 978</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-979"><a href="#BigQuery.Generator-979"><span class="linenos"> 979</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-980"><a href="#BigQuery.Generator-980"><span class="linenos"> 980</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-981"><a href="#BigQuery.Generator-981"><span class="linenos"> 981</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-982"><a href="#BigQuery.Generator-982"><span class="linenos"> 982</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-983"><a href="#BigQuery.Generator-983"><span class="linenos"> 983</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-984"><a href="#BigQuery.Generator-984"><span class="linenos"> 984</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-985"><a href="#BigQuery.Generator-985"><span class="linenos"> 985</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UUID</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-986"><a href="#BigQuery.Generator-986"><span class="linenos"> 986</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-987"><a href="#BigQuery.Generator-987"><span class="linenos"> 987</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-988"><a href="#BigQuery.Generator-988"><span class="linenos"> 988</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-989"><a href="#BigQuery.Generator-989"><span class="linenos"> 989</span></a> <span class="p">}</span> -</span><span id="BigQuery.Generator-990"><a href="#BigQuery.Generator-990"><span class="linenos"> 990</span></a> -</span><span id="BigQuery.Generator-991"><a href="#BigQuery.Generator-991"><span class="linenos"> 991</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Generator-992"><a href="#BigQuery.Generator-992"><span class="linenos"> 992</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="BigQuery.Generator-993"><a href="#BigQuery.Generator-993"><span class="linenos"> 993</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="BigQuery.Generator-994"><a href="#BigQuery.Generator-994"><span class="linenos"> 994</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="BigQuery.Generator-995"><a href="#BigQuery.Generator-995"><span class="linenos"> 995</span></a> <span class="p">}</span> -</span><span id="BigQuery.Generator-996"><a href="#BigQuery.Generator-996"><span class="linenos"> 996</span></a> -</span><span id="BigQuery.Generator-997"><a href="#BigQuery.Generator-997"><span class="linenos"> 997</span></a> <span class="c1"># WINDOW comes after QUALIFY</span> -</span><span id="BigQuery.Generator-998"><a href="#BigQuery.Generator-998"><span class="linenos"> 998</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#window_clause</span> -</span><span id="BigQuery.Generator-999"><a href="#BigQuery.Generator-999"><span class="linenos"> 999</span></a> <span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Generator-1000"><a href="#BigQuery.Generator-1000"><span class="linenos">1000</span></a> <span class="s2">"qualify"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"qualify"</span><span class="p">],</span> -</span><span id="BigQuery.Generator-1001"><a href="#BigQuery.Generator-1001"><span class="linenos">1001</span></a> <span class="s2">"windows"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"windows"</span><span class="p">],</span> -</span><span id="BigQuery.Generator-1002"><a href="#BigQuery.Generator-1002"><span class="linenos">1002</span></a> <span class="p">}</span> -</span><span id="BigQuery.Generator-1003"><a href="#BigQuery.Generator-1003"><span class="linenos">1003</span></a> -</span><span id="BigQuery.Generator-1004"><a href="#BigQuery.Generator-1004"><span class="linenos">1004</span></a> <span class="c1"># from: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords</span> -</span><span id="BigQuery.Generator-1005"><a href="#BigQuery.Generator-1005"><span class="linenos">1005</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Generator-1006"><a href="#BigQuery.Generator-1006"><span class="linenos">1006</span></a> <span class="s2">"all"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1007"><a href="#BigQuery.Generator-1007"><span class="linenos">1007</span></a> <span class="s2">"and"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1008"><a href="#BigQuery.Generator-1008"><span class="linenos">1008</span></a> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1009"><a href="#BigQuery.Generator-1009"><span class="linenos">1009</span></a> <span class="s2">"array"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1010"><a href="#BigQuery.Generator-1010"><span class="linenos">1010</span></a> <span class="s2">"as"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1011"><a href="#BigQuery.Generator-1011"><span class="linenos">1011</span></a> <span class="s2">"asc"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1012"><a href="#BigQuery.Generator-1012"><span class="linenos">1012</span></a> <span class="s2">"assert_rows_modified"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1013"><a href="#BigQuery.Generator-1013"><span class="linenos">1013</span></a> <span class="s2">"at"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1014"><a href="#BigQuery.Generator-1014"><span class="linenos">1014</span></a> <span class="s2">"between"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1015"><a href="#BigQuery.Generator-1015"><span class="linenos">1015</span></a> <span class="s2">"by"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1016"><a href="#BigQuery.Generator-1016"><span class="linenos">1016</span></a> <span class="s2">"case"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1017"><a href="#BigQuery.Generator-1017"><span class="linenos">1017</span></a> <span class="s2">"cast"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1018"><a href="#BigQuery.Generator-1018"><span class="linenos">1018</span></a> <span class="s2">"collate"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1019"><a href="#BigQuery.Generator-1019"><span class="linenos">1019</span></a> <span class="s2">"contains"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1020"><a href="#BigQuery.Generator-1020"><span class="linenos">1020</span></a> <span class="s2">"create"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1021"><a href="#BigQuery.Generator-1021"><span class="linenos">1021</span></a> <span class="s2">"cross"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1022"><a href="#BigQuery.Generator-1022"><span class="linenos">1022</span></a> <span class="s2">"cube"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1023"><a href="#BigQuery.Generator-1023"><span class="linenos">1023</span></a> <span class="s2">"current"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1024"><a href="#BigQuery.Generator-1024"><span class="linenos">1024</span></a> <span class="s2">"default"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1025"><a href="#BigQuery.Generator-1025"><span class="linenos">1025</span></a> <span class="s2">"define"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1026"><a href="#BigQuery.Generator-1026"><span class="linenos">1026</span></a> <span class="s2">"desc"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1027"><a href="#BigQuery.Generator-1027"><span class="linenos">1027</span></a> <span class="s2">"distinct"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1028"><a href="#BigQuery.Generator-1028"><span class="linenos">1028</span></a> <span class="s2">"else"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1029"><a href="#BigQuery.Generator-1029"><span class="linenos">1029</span></a> <span class="s2">"end"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1030"><a href="#BigQuery.Generator-1030"><span class="linenos">1030</span></a> <span class="s2">"enum"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1031"><a href="#BigQuery.Generator-1031"><span class="linenos">1031</span></a> <span class="s2">"escape"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1032"><a href="#BigQuery.Generator-1032"><span class="linenos">1032</span></a> <span class="s2">"except"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1033"><a href="#BigQuery.Generator-1033"><span class="linenos">1033</span></a> <span class="s2">"exclude"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1034"><a href="#BigQuery.Generator-1034"><span class="linenos">1034</span></a> <span class="s2">"exists"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1035"><a href="#BigQuery.Generator-1035"><span class="linenos">1035</span></a> <span class="s2">"extract"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1036"><a href="#BigQuery.Generator-1036"><span class="linenos">1036</span></a> <span class="s2">"false"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1037"><a href="#BigQuery.Generator-1037"><span class="linenos">1037</span></a> <span class="s2">"fetch"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1038"><a href="#BigQuery.Generator-1038"><span class="linenos">1038</span></a> <span class="s2">"following"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1039"><a href="#BigQuery.Generator-1039"><span class="linenos">1039</span></a> <span class="s2">"for"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1040"><a href="#BigQuery.Generator-1040"><span class="linenos">1040</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1041"><a href="#BigQuery.Generator-1041"><span class="linenos">1041</span></a> <span class="s2">"full"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1042"><a href="#BigQuery.Generator-1042"><span class="linenos">1042</span></a> <span class="s2">"group"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1043"><a href="#BigQuery.Generator-1043"><span class="linenos">1043</span></a> <span class="s2">"grouping"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1044"><a href="#BigQuery.Generator-1044"><span class="linenos">1044</span></a> <span class="s2">"groups"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1045"><a href="#BigQuery.Generator-1045"><span class="linenos">1045</span></a> <span class="s2">"hash"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1046"><a href="#BigQuery.Generator-1046"><span class="linenos">1046</span></a> <span class="s2">"having"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1047"><a href="#BigQuery.Generator-1047"><span class="linenos">1047</span></a> <span class="s2">"if"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1048"><a href="#BigQuery.Generator-1048"><span class="linenos">1048</span></a> <span class="s2">"ignore"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1049"><a href="#BigQuery.Generator-1049"><span class="linenos">1049</span></a> <span class="s2">"in"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1050"><a href="#BigQuery.Generator-1050"><span class="linenos">1050</span></a> <span class="s2">"inner"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1051"><a href="#BigQuery.Generator-1051"><span class="linenos">1051</span></a> <span class="s2">"intersect"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1052"><a href="#BigQuery.Generator-1052"><span class="linenos">1052</span></a> <span class="s2">"interval"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1053"><a href="#BigQuery.Generator-1053"><span class="linenos">1053</span></a> <span class="s2">"into"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1054"><a href="#BigQuery.Generator-1054"><span class="linenos">1054</span></a> <span class="s2">"is"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1055"><a href="#BigQuery.Generator-1055"><span class="linenos">1055</span></a> <span class="s2">"join"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1056"><a href="#BigQuery.Generator-1056"><span class="linenos">1056</span></a> <span class="s2">"lateral"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1057"><a href="#BigQuery.Generator-1057"><span class="linenos">1057</span></a> <span class="s2">"left"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1058"><a href="#BigQuery.Generator-1058"><span class="linenos">1058</span></a> <span class="s2">"like"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1059"><a href="#BigQuery.Generator-1059"><span class="linenos">1059</span></a> <span class="s2">"limit"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1060"><a href="#BigQuery.Generator-1060"><span class="linenos">1060</span></a> <span class="s2">"lookup"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1061"><a href="#BigQuery.Generator-1061"><span class="linenos">1061</span></a> <span class="s2">"merge"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1062"><a href="#BigQuery.Generator-1062"><span class="linenos">1062</span></a> <span class="s2">"natural"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1063"><a href="#BigQuery.Generator-1063"><span class="linenos">1063</span></a> <span class="s2">"new"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1064"><a href="#BigQuery.Generator-1064"><span class="linenos">1064</span></a> <span class="s2">"no"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1065"><a href="#BigQuery.Generator-1065"><span class="linenos">1065</span></a> <span class="s2">"not"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1066"><a href="#BigQuery.Generator-1066"><span class="linenos">1066</span></a> <span class="s2">"null"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1067"><a href="#BigQuery.Generator-1067"><span class="linenos">1067</span></a> <span class="s2">"nulls"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1068"><a href="#BigQuery.Generator-1068"><span class="linenos">1068</span></a> <span class="s2">"of"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1069"><a href="#BigQuery.Generator-1069"><span class="linenos">1069</span></a> <span class="s2">"on"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1070"><a href="#BigQuery.Generator-1070"><span class="linenos">1070</span></a> <span class="s2">"or"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1071"><a href="#BigQuery.Generator-1071"><span class="linenos">1071</span></a> <span class="s2">"order"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1072"><a href="#BigQuery.Generator-1072"><span class="linenos">1072</span></a> <span class="s2">"outer"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1073"><a href="#BigQuery.Generator-1073"><span class="linenos">1073</span></a> <span class="s2">"over"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1074"><a href="#BigQuery.Generator-1074"><span class="linenos">1074</span></a> <span class="s2">"partition"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1075"><a href="#BigQuery.Generator-1075"><span class="linenos">1075</span></a> <span class="s2">"preceding"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1076"><a href="#BigQuery.Generator-1076"><span class="linenos">1076</span></a> <span class="s2">"proto"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1077"><a href="#BigQuery.Generator-1077"><span class="linenos">1077</span></a> <span class="s2">"qualify"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1078"><a href="#BigQuery.Generator-1078"><span class="linenos">1078</span></a> <span class="s2">"range"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1079"><a href="#BigQuery.Generator-1079"><span class="linenos">1079</span></a> <span class="s2">"recursive"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1080"><a href="#BigQuery.Generator-1080"><span class="linenos">1080</span></a> <span class="s2">"respect"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1081"><a href="#BigQuery.Generator-1081"><span class="linenos">1081</span></a> <span class="s2">"right"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1082"><a href="#BigQuery.Generator-1082"><span class="linenos">1082</span></a> <span class="s2">"rollup"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1083"><a href="#BigQuery.Generator-1083"><span class="linenos">1083</span></a> <span class="s2">"rows"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1084"><a href="#BigQuery.Generator-1084"><span class="linenos">1084</span></a> <span class="s2">"select"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1085"><a href="#BigQuery.Generator-1085"><span class="linenos">1085</span></a> <span class="s2">"set"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1086"><a href="#BigQuery.Generator-1086"><span class="linenos">1086</span></a> <span class="s2">"some"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1087"><a href="#BigQuery.Generator-1087"><span class="linenos">1087</span></a> <span class="s2">"struct"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1088"><a href="#BigQuery.Generator-1088"><span class="linenos">1088</span></a> <span class="s2">"tablesample"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1089"><a href="#BigQuery.Generator-1089"><span class="linenos">1089</span></a> <span class="s2">"then"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1090"><a href="#BigQuery.Generator-1090"><span class="linenos">1090</span></a> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1091"><a href="#BigQuery.Generator-1091"><span class="linenos">1091</span></a> <span class="s2">"treat"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1092"><a href="#BigQuery.Generator-1092"><span class="linenos">1092</span></a> <span class="s2">"true"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1093"><a href="#BigQuery.Generator-1093"><span class="linenos">1093</span></a> <span class="s2">"unbounded"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1094"><a href="#BigQuery.Generator-1094"><span class="linenos">1094</span></a> <span class="s2">"union"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1095"><a href="#BigQuery.Generator-1095"><span class="linenos">1095</span></a> <span class="s2">"unnest"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1096"><a href="#BigQuery.Generator-1096"><span class="linenos">1096</span></a> <span class="s2">"using"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1097"><a href="#BigQuery.Generator-1097"><span class="linenos">1097</span></a> <span class="s2">"when"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1098"><a href="#BigQuery.Generator-1098"><span class="linenos">1098</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1099"><a href="#BigQuery.Generator-1099"><span class="linenos">1099</span></a> <span class="s2">"window"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1100"><a href="#BigQuery.Generator-1100"><span class="linenos">1100</span></a> <span class="s2">"with"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1101"><a href="#BigQuery.Generator-1101"><span class="linenos">1101</span></a> <span class="s2">"within"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1102"><a href="#BigQuery.Generator-1102"><span class="linenos">1102</span></a> <span class="p">}</span> -</span><span id="BigQuery.Generator-1103"><a href="#BigQuery.Generator-1103"><span class="linenos">1103</span></a> -</span><span id="BigQuery.Generator-1104"><a href="#BigQuery.Generator-1104"><span class="linenos">1104</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1105"><a href="#BigQuery.Generator-1105"><span class="linenos">1105</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery.Generator-1106"><a href="#BigQuery.Generator-1106"><span class="linenos">1106</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="BigQuery.Generator-1107"><a href="#BigQuery.Generator-1107"><span class="linenos">1107</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery.Generator-1108"><a href="#BigQuery.Generator-1108"><span class="linenos">1108</span></a> <span class="s2">"MOD"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1109"><a href="#BigQuery.Generator-1109"><span class="linenos">1109</span></a> <span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <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">Paren</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1110"><a href="#BigQuery.Generator-1110"><span class="linenos">1110</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</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="k">else</span> <span class="n">expr</span><span class="p">,</span> -</span><span id="BigQuery.Generator-1111"><a href="#BigQuery.Generator-1111"><span class="linenos">1111</span></a> <span class="p">)</span> -</span><span id="BigQuery.Generator-1112"><a href="#BigQuery.Generator-1112"><span class="linenos">1112</span></a> -</span><span id="BigQuery.Generator-1113"><a href="#BigQuery.Generator-1113"><span class="linenos">1113</span></a> <span class="k">def</span> <span class="nf">column_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1114"><a href="#BigQuery.Generator-1114"><span class="linenos">1114</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_column"</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1115"><a href="#BigQuery.Generator-1115"><span class="linenos">1115</span></a> <span class="c1"># If a column reference is of the form `dataset.table`.name, we need</span> -</span><span id="BigQuery.Generator-1116"><a href="#BigQuery.Generator-1116"><span class="linenos">1116</span></a> <span class="c1"># to preserve the quoted table path, otherwise the reference breaks</span> -</span><span id="BigQuery.Generator-1117"><a href="#BigQuery.Generator-1117"><span class="linenos">1117</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> -</span><span id="BigQuery.Generator-1118"><a href="#BigQuery.Generator-1118"><span class="linenos">1118</span></a> <span class="n">table_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</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="BigQuery.Generator-1119"><a href="#BigQuery.Generator-1119"><span class="linenos">1119</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_path</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator-1120"><a href="#BigQuery.Generator-1120"><span class="linenos">1120</span></a> -</span><span id="BigQuery.Generator-1121"><a href="#BigQuery.Generator-1121"><span class="linenos">1121</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">column_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1122"><a href="#BigQuery.Generator-1122"><span class="linenos">1122</span></a> -</span><span id="BigQuery.Generator-1123"><a href="#BigQuery.Generator-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1124"><a href="#BigQuery.Generator-1124"><span class="linenos">1124</span></a> <span class="c1"># Depending on the context, `x.y` may not resolve to the same data source as `x`.`y`, so</span> -</span><span id="BigQuery.Generator-1125"><a href="#BigQuery.Generator-1125"><span class="linenos">1125</span></a> <span class="c1"># we need to make sure the correct quoting is used in each case.</span> -</span><span id="BigQuery.Generator-1126"><a href="#BigQuery.Generator-1126"><span class="linenos">1126</span></a> <span class="c1">#</span> -</span><span id="BigQuery.Generator-1127"><a href="#BigQuery.Generator-1127"><span class="linenos">1127</span></a> <span class="c1"># For example, if there is a CTE x that clashes with a schema name, then the former will</span> -</span><span id="BigQuery.Generator-1128"><a href="#BigQuery.Generator-1128"><span class="linenos">1128</span></a> <span class="c1"># return the table y in that schema, whereas the latter will return the CTE's y column:</span> -</span><span id="BigQuery.Generator-1129"><a href="#BigQuery.Generator-1129"><span class="linenos">1129</span></a> <span class="c1">#</span> -</span><span id="BigQuery.Generator-1130"><a href="#BigQuery.Generator-1130"><span class="linenos">1130</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x.y` -> cross join</span> -</span><span id="BigQuery.Generator-1131"><a href="#BigQuery.Generator-1131"><span class="linenos">1131</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x`.`y` -> implicit unnest</span> -</span><span id="BigQuery.Generator-1132"><a href="#BigQuery.Generator-1132"><span class="linenos">1132</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_table"</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1133"><a href="#BigQuery.Generator-1133"><span class="linenos">1133</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1134"><a href="#BigQuery.Generator-1134"><span class="linenos">1134</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="BigQuery.Generator-1135"><a href="#BigQuery.Generator-1135"><span class="linenos">1135</span></a> -</span><span id="BigQuery.Generator-1136"><a href="#BigQuery.Generator-1136"><span class="linenos">1136</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">table_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1137"><a href="#BigQuery.Generator-1137"><span class="linenos">1137</span></a> -</span><span id="BigQuery.Generator-1138"><a href="#BigQuery.Generator-1138"><span class="linenos">1138</span></a> <span class="k">def</span> <span class="nf">timetostr_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1139"><a href="#BigQuery.Generator-1139"><span class="linenos">1139</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery.Generator-1140"><a href="#BigQuery.Generator-1140"><span class="linenos">1140</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">TsOrDsToDatetime</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1141"><a href="#BigQuery.Generator-1141"><span class="linenos">1141</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATETIME"</span> -</span><span id="BigQuery.Generator-1142"><a href="#BigQuery.Generator-1142"><span class="linenos">1142</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">TsOrDsToTimestamp</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1143"><a href="#BigQuery.Generator-1143"><span class="linenos">1143</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_TIMESTAMP"</span> -</span><span id="BigQuery.Generator-1144"><a href="#BigQuery.Generator-1144"><span class="linenos">1144</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1145"><a href="#BigQuery.Generator-1145"><span class="linenos">1145</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATE"</span> -</span><span id="BigQuery.Generator-1146"><a href="#BigQuery.Generator-1146"><span class="linenos">1146</span></a> -</span><span id="BigQuery.Generator-1147"><a href="#BigQuery.Generator-1147"><span class="linenos">1147</span></a> <span class="n">time_expr</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="BigQuery.Generator-1148"><a href="#BigQuery.Generator-1148"><span class="linenos">1148</span></a> <span class="n">this</span> -</span><span id="BigQuery.Generator-1149"><a href="#BigQuery.Generator-1149"><span class="linenos">1149</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="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">))</span> -</span><span id="BigQuery.Generator-1150"><a href="#BigQuery.Generator-1150"><span class="linenos">1150</span></a> <span class="k">else</span> <span class="n">expression</span> -</span><span id="BigQuery.Generator-1151"><a href="#BigQuery.Generator-1151"><span class="linenos">1151</span></a> <span class="p">)</span> -</span><span id="BigQuery.Generator-1152"><a href="#BigQuery.Generator-1152"><span class="linenos">1152</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">time_expr</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1153"><a href="#BigQuery.Generator-1153"><span class="linenos">1153</span></a> -</span><span id="BigQuery.Generator-1154"><a href="#BigQuery.Generator-1154"><span class="linenos">1154</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1155"><a href="#BigQuery.Generator-1155"><span class="linenos">1155</span></a> <span class="c1"># Operands of = cannot be NULL in BigQuery</span> -</span><span id="BigQuery.Generator-1156"><a href="#BigQuery.Generator-1156"><span class="linenos">1156</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">right</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1157"><a href="#BigQuery.Generator-1157"><span class="linenos">1157</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1158"><a href="#BigQuery.Generator-1158"><span class="linenos">1158</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> -</span><span id="BigQuery.Generator-1159"><a href="#BigQuery.Generator-1159"><span class="linenos">1159</span></a> -</span><span id="BigQuery.Generator-1160"><a href="#BigQuery.Generator-1160"><span class="linenos">1160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1161"><a href="#BigQuery.Generator-1161"><span class="linenos">1161</span></a> -</span><span id="BigQuery.Generator-1162"><a href="#BigQuery.Generator-1162"><span class="linenos">1162</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1163"><a href="#BigQuery.Generator-1163"><span class="linenos">1163</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> -</span><span id="BigQuery.Generator-1164"><a href="#BigQuery.Generator-1164"><span class="linenos">1164</span></a> -</span><span id="BigQuery.Generator-1165"><a href="#BigQuery.Generator-1165"><span class="linenos">1165</span></a> <span class="c1"># BigQuery allows CAST(.. AS {STRING|TIMESTAMP} [FORMAT <fmt> [AT TIME ZONE <tz>]]).</span> -</span><span id="BigQuery.Generator-1166"><a href="#BigQuery.Generator-1166"><span class="linenos">1166</span></a> <span class="c1"># Only the TIMESTAMP one should use the below conversion, when AT TIME ZONE is included.</span> -</span><span id="BigQuery.Generator-1167"><a href="#BigQuery.Generator-1167"><span class="linenos">1167</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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1168"><a href="#BigQuery.Generator-1168"><span class="linenos">1168</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery.Generator-1169"><a href="#BigQuery.Generator-1169"><span class="linenos">1169</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">))</span> -</span><span id="BigQuery.Generator-1170"><a href="#BigQuery.Generator-1170"><span class="linenos">1170</span></a> <span class="p">)</span> -</span><span id="BigQuery.Generator-1171"><a href="#BigQuery.Generator-1171"><span class="linenos">1171</span></a> -</span><span id="BigQuery.Generator-1172"><a href="#BigQuery.Generator-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">attimezone_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1173"><a href="#BigQuery.Generator-1173"><span class="linenos">1173</span></a> -</span><span id="BigQuery.Generator-1174"><a href="#BigQuery.Generator-1174"><span class="linenos">1174</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1175"><a href="#BigQuery.Generator-1175"><span class="linenos">1175</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"SAFE_"</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1176"><a href="#BigQuery.Generator-1176"><span class="linenos">1176</span></a> -</span><span id="BigQuery.Generator-1177"><a href="#BigQuery.Generator-1177"><span class="linenos">1177</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1178"><a href="#BigQuery.Generator-1178"><span class="linenos">1178</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery.Generator-1179"><a href="#BigQuery.Generator-1179"><span class="linenos">1179</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator-833"><a href="#BigQuery.Generator-833"><span class="linenos"> 833</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="BigQuery.Generator-834"><a href="#BigQuery.Generator-834"><span class="linenos"> 834</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-835"><a href="#BigQuery.Generator-835"><span class="linenos"> 835</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-836"><a href="#BigQuery.Generator-836"><span class="linenos"> 836</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-837"><a href="#BigQuery.Generator-837"><span class="linenos"> 837</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-838"><a href="#BigQuery.Generator-838"><span class="linenos"> 838</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="BigQuery.Generator-839"><a href="#BigQuery.Generator-839"><span class="linenos"> 839</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-840"><a href="#BigQuery.Generator-840"><span class="linenos"> 840</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-841"><a href="#BigQuery.Generator-841"><span class="linenos"> 841</span></a> <span class="n">UNNEST_WITH_ORDINALITY</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-842"><a href="#BigQuery.Generator-842"><span class="linenos"> 842</span></a> <span class="n">COLLATE_IS_FUNC</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Generator-843"><a href="#BigQuery.Generator-843"><span class="linenos"> 843</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Generator-844"><a href="#BigQuery.Generator-844"><span class="linenos"> 844</span></a> <span class="n">SUPPORTS_TABLE_ALIAS_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-845"><a href="#BigQuery.Generator-845"><span class="linenos"> 845</span></a> <span class="n">UNPIVOT_ALIASES_ARE_IDENTIFIERS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-846"><a href="#BigQuery.Generator-846"><span class="linenos"> 846</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="BigQuery.Generator-847"><a href="#BigQuery.Generator-847"><span class="linenos"> 847</span></a> <span class="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-848"><a href="#BigQuery.Generator-848"><span class="linenos"> 848</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Generator-849"><a href="#BigQuery.Generator-849"><span class="linenos"> 849</span></a> <span class="n">JSON_PATH_SINGLE_QUOTE_ESCAPE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Generator-850"><a href="#BigQuery.Generator-850"><span class="linenos"> 850</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Generator-851"><a href="#BigQuery.Generator-851"><span class="linenos"> 851</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-852"><a href="#BigQuery.Generator-852"><span class="linenos"> 852</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> +</span><span id="BigQuery.Generator-853"><a href="#BigQuery.Generator-853"><span class="linenos"> 853</span></a> <span class="n">HEX_FUNC</span> <span class="o">=</span> <span class="s2">"TO_HEX"</span> +</span><span id="BigQuery.Generator-854"><a href="#BigQuery.Generator-854"><span class="linenos"> 854</span></a> <span class="n">WITH_PROPERTIES_PREFIX</span> <span class="o">=</span> <span class="s2">"OPTIONS"</span> +</span><span id="BigQuery.Generator-855"><a href="#BigQuery.Generator-855"><span class="linenos"> 855</span></a> <span class="n">SUPPORTS_EXPLODING_PROJECTIONS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-856"><a href="#BigQuery.Generator-856"><span class="linenos"> 856</span></a> <span class="n">EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-857"><a href="#BigQuery.Generator-857"><span class="linenos"> 857</span></a> <span class="n">SUPPORTS_UNIX_SECONDS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Generator-858"><a href="#BigQuery.Generator-858"><span class="linenos"> 858</span></a> +</span><span id="BigQuery.Generator-859"><a href="#BigQuery.Generator-859"><span class="linenos"> 859</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Generator-860"><a href="#BigQuery.Generator-860"><span class="linenos"> 860</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="BigQuery.Generator-861"><a href="#BigQuery.Generator-861"><span class="linenos"> 861</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-862"><a href="#BigQuery.Generator-862"><span class="linenos"> 862</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-863"><a href="#BigQuery.Generator-863"><span class="linenos"> 863</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-864"><a href="#BigQuery.Generator-864"><span class="linenos"> 864</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> +</span><span id="BigQuery.Generator-865"><a href="#BigQuery.Generator-865"><span class="linenos"> 865</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">_array_contains_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-866"><a href="#BigQuery.Generator-866"><span class="linenos"> 866</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">filter_array_using_unnest</span><span class="p">,</span> +</span><span id="BigQuery.Generator-867"><a href="#BigQuery.Generator-867"><span class="linenos"> 867</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_precision_parameterized_types</span><span class="p">]),</span> +</span><span id="BigQuery.Generator-868"><a href="#BigQuery.Generator-868"><span class="linenos"> 868</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> +</span><span id="BigQuery.Generator-869"><a href="#BigQuery.Generator-869"><span class="linenos"> 869</span></a> <span class="sa">f</span><span class="s2">"DEFAULT COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator-870"><a href="#BigQuery.Generator-870"><span class="linenos"> 870</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> +</span><span id="BigQuery.Generator-871"><a href="#BigQuery.Generator-871"><span class="linenos"> 871</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator-872"><a href="#BigQuery.Generator-872"><span class="linenos"> 872</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-873"><a href="#BigQuery.Generator-873"><span class="linenos"> 873</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"COMMIT TRANSACTION"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-874"><a href="#BigQuery.Generator-874"><span class="linenos"> 874</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COUNTIF"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-875"><a href="#BigQuery.Generator-875"><span class="linenos"> 875</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-876"><a href="#BigQuery.Generator-876"><span class="linenos"> 876</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_pushdown_cte_column_names</span><span class="p">]),</span> +</span><span id="BigQuery.Generator-877"><a href="#BigQuery.Generator-877"><span class="linenos"> 877</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-878"><a href="#BigQuery.Generator-878"><span class="linenos"> 878</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery.Generator-879"><a href="#BigQuery.Generator-879"><span class="linenos"> 879</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">unit_to_var</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="BigQuery.Generator-880"><a href="#BigQuery.Generator-880"><span class="linenos"> 880</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-881"><a href="#BigQuery.Generator-881"><span class="linenos"> 881</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-882"><a href="#BigQuery.Generator-882"><span class="linenos"> 882</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-883"><a href="#BigQuery.Generator-883"><span class="linenos"> 883</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-884"><a href="#BigQuery.Generator-884"><span class="linenos"> 884</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-885"><a href="#BigQuery.Generator-885"><span class="linenos"> 885</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-886"><a href="#BigQuery.Generator-886"><span class="linenos"> 886</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery.Generator-887"><a href="#BigQuery.Generator-887"><span class="linenos"> 887</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)</span> +</span><span id="BigQuery.Generator-888"><a href="#BigQuery.Generator-888"><span class="linenos"> 888</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-889"><a href="#BigQuery.Generator-889"><span class="linenos"> 889</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromTimeZone</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery.Generator-890"><a href="#BigQuery.Generator-890"><span class="linenos"> 890</span></a> <span class="s2">"DATETIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">)),</span> <span class="s2">"'UTC'"</span> +</span><span id="BigQuery.Generator-891"><a href="#BigQuery.Generator-891"><span class="linenos"> 891</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-892"><a href="#BigQuery.Generator-892"><span class="linenos"> 892</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GENERATE_ARRAY"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-893"><a href="#BigQuery.Generator-893"><span class="linenos"> 893</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-894"><a href="#BigQuery.Generator-894"><span class="linenos"> 894</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> +</span><span id="BigQuery.Generator-895"><a href="#BigQuery.Generator-895"><span class="linenos"> 895</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(</span><span class="n">false_value</span><span class="o">=</span><span class="s2">"NULL"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-896"><a href="#BigQuery.Generator-896"><span class="linenos"> 896</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-897"><a href="#BigQuery.Generator-897"><span class="linenos"> 897</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-898"><a href="#BigQuery.Generator-898"><span class="linenos"> 898</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Int64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"INT64"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-899"><a href="#BigQuery.Generator-899"><span class="linenos"> 899</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-900"><a href="#BigQuery.Generator-900"><span class="linenos"> 900</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractArray</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-901"><a href="#BigQuery.Generator-901"><span class="linenos"> 901</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_extract_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-902"><a href="#BigQuery.Generator-902"><span class="linenos"> 902</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_JSON_STRING"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-903"><a href="#BigQuery.Generator-903"><span class="linenos"> 903</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">_levenshtein_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-904"><a href="#BigQuery.Generator-904"><span class="linenos"> 904</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="BigQuery.Generator-905"><a href="#BigQuery.Generator-905"><span class="linenos"> 905</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> +</span><span id="BigQuery.Generator-906"><a href="#BigQuery.Generator-906"><span class="linenos"> 906</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-907"><a href="#BigQuery.Generator-907"><span class="linenos"> 907</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="BigQuery.Generator-908"><a href="#BigQuery.Generator-908"><span class="linenos"> 908</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-909"><a href="#BigQuery.Generator-909"><span class="linenos"> 909</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery.Generator-910"><a href="#BigQuery.Generator-910"><span class="linenos"> 910</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-911"><a href="#BigQuery.Generator-911"><span class="linenos"> 911</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="BigQuery.Generator-912"><a href="#BigQuery.Generator-912"><span class="linenos"> 912</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="BigQuery.Generator-913"><a href="#BigQuery.Generator-913"><span class="linenos"> 913</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-914"><a href="#BigQuery.Generator-914"><span class="linenos"> 914</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"occurrence"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-915"><a href="#BigQuery.Generator-915"><span class="linenos"> 915</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-916"><a href="#BigQuery.Generator-916"><span class="linenos"> 916</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtractAll</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery.Generator-917"><a href="#BigQuery.Generator-917"><span class="linenos"> 917</span></a> <span class="s2">"REGEXP_EXTRACT_ALL"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span> +</span><span id="BigQuery.Generator-918"><a href="#BigQuery.Generator-918"><span class="linenos"> 918</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-919"><a href="#BigQuery.Generator-919"><span class="linenos"> 919</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="n">regexp_replace_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-920"><a href="#BigQuery.Generator-920"><span class="linenos"> 920</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_CONTAINS"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-921"><a href="#BigQuery.Generator-921"><span class="linenos"> 921</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-922"><a href="#BigQuery.Generator-922"><span class="linenos"> 922</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"ROLLBACK TRANSACTION"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-923"><a href="#BigQuery.Generator-923"><span class="linenos"> 923</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="BigQuery.Generator-924"><a href="#BigQuery.Generator-924"><span class="linenos"> 924</span></a> <span class="p">[</span> +</span><span id="BigQuery.Generator-925"><a href="#BigQuery.Generator-925"><span class="linenos"> 925</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(),</span> +</span><span id="BigQuery.Generator-926"><a href="#BigQuery.Generator-926"><span class="linenos"> 926</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> +</span><span id="BigQuery.Generator-927"><a href="#BigQuery.Generator-927"><span class="linenos"> 927</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="BigQuery.Generator-928"><a href="#BigQuery.Generator-928"><span class="linenos"> 928</span></a> <span class="n">_alias_ordered_group</span><span class="p">,</span> +</span><span id="BigQuery.Generator-929"><a href="#BigQuery.Generator-929"><span class="linenos"> 929</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">,</span> +</span><span id="BigQuery.Generator-930"><a href="#BigQuery.Generator-930"><span class="linenos"> 930</span></a> <span class="p">]</span> +</span><span id="BigQuery.Generator-931"><a href="#BigQuery.Generator-931"><span class="linenos"> 931</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-932"><a href="#BigQuery.Generator-932"><span class="linenos"> 932</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SHA1"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-933"><a href="#BigQuery.Generator-933"><span class="linenos"> 933</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SHA2</span><span class="p">:</span> <span class="n">sha256_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-934"><a href="#BigQuery.Generator-934"><span class="linenos"> 934</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> +</span><span id="BigQuery.Generator-935"><a href="#BigQuery.Generator-935"><span class="linenos"> 935</span></a> <span class="s2">"DETERMINISTIC"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span> +</span><span id="BigQuery.Generator-936"><a href="#BigQuery.Generator-936"><span class="linenos"> 936</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-937"><a href="#BigQuery.Generator-937"><span class="linenos"> 937</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">String</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-938"><a href="#BigQuery.Generator-938"><span class="linenos"> 938</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-939"><a href="#BigQuery.Generator-939"><span class="linenos"> 939</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-940"><a href="#BigQuery.Generator-940"><span class="linenos"> 940</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_datetime_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-941"><a href="#BigQuery.Generator-941"><span class="linenos"> 941</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-942"><a href="#BigQuery.Generator-942"><span class="linenos"> 942</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-943"><a href="#BigQuery.Generator-943"><span class="linenos"> 943</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-944"><a href="#BigQuery.Generator-944"><span class="linenos"> 944</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-945"><a href="#BigQuery.Generator-945"><span class="linenos"> 945</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-946"><a href="#BigQuery.Generator-946"><span class="linenos"> 946</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP_DIFF"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-947"><a href="#BigQuery.Generator-947"><span class="linenos"> 947</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">date_add_interval_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-948"><a href="#BigQuery.Generator-948"><span class="linenos"> 948</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-949"><a href="#BigQuery.Generator-949"><span class="linenos"> 949</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-950"><a href="#BigQuery.Generator-950"><span class="linenos"> 950</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-951"><a href="#BigQuery.Generator-951"><span class="linenos"> 951</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">_ts_or_ds_diff_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-952"><a href="#BigQuery.Generator-952"><span class="linenos"> 952</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-953"><a href="#BigQuery.Generator-953"><span class="linenos"> 953</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-954"><a href="#BigQuery.Generator-954"><span class="linenos"> 954</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-955"><a href="#BigQuery.Generator-955"><span class="linenos"> 955</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-956"><a href="#BigQuery.Generator-956"><span class="linenos"> 956</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_DATE"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-957"><a href="#BigQuery.Generator-957"><span class="linenos"> 957</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-958"><a href="#BigQuery.Generator-958"><span class="linenos"> 958</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uuid</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"GENERATE_UUID()"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-959"><a href="#BigQuery.Generator-959"><span class="linenos"> 959</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> +</span><span id="BigQuery.Generator-960"><a href="#BigQuery.Generator-960"><span class="linenos"> 960</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-961"><a href="#BigQuery.Generator-961"><span class="linenos"> 961</span></a> <span class="p">}</span> +</span><span id="BigQuery.Generator-962"><a href="#BigQuery.Generator-962"><span class="linenos"> 962</span></a> +</span><span id="BigQuery.Generator-963"><a href="#BigQuery.Generator-963"><span class="linenos"> 963</span></a> <span class="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Generator-964"><a href="#BigQuery.Generator-964"><span class="linenos"> 964</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> +</span><span id="BigQuery.Generator-965"><a href="#BigQuery.Generator-965"><span class="linenos"> 965</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> +</span><span id="BigQuery.Generator-966"><a href="#BigQuery.Generator-966"><span class="linenos"> 966</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> +</span><span id="BigQuery.Generator-967"><a href="#BigQuery.Generator-967"><span class="linenos"> 967</span></a> <span class="p">}</span> +</span><span id="BigQuery.Generator-968"><a href="#BigQuery.Generator-968"><span class="linenos"> 968</span></a> +</span><span id="BigQuery.Generator-969"><a href="#BigQuery.Generator-969"><span class="linenos"> 969</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Generator-970"><a href="#BigQuery.Generator-970"><span class="linenos"> 970</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="BigQuery.Generator-971"><a href="#BigQuery.Generator-971"><span class="linenos"> 971</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-972"><a href="#BigQuery.Generator-972"><span class="linenos"> 972</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-973"><a href="#BigQuery.Generator-973"><span class="linenos"> 973</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-974"><a href="#BigQuery.Generator-974"><span class="linenos"> 974</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-975"><a href="#BigQuery.Generator-975"><span class="linenos"> 975</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-976"><a href="#BigQuery.Generator-976"><span class="linenos"> 976</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">:</span> <span class="s2">"NUMERIC"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-977"><a href="#BigQuery.Generator-977"><span class="linenos"> 977</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-978"><a href="#BigQuery.Generator-978"><span class="linenos"> 978</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-979"><a href="#BigQuery.Generator-979"><span class="linenos"> 979</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-980"><a href="#BigQuery.Generator-980"><span class="linenos"> 980</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-981"><a href="#BigQuery.Generator-981"><span class="linenos"> 981</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-982"><a href="#BigQuery.Generator-982"><span class="linenos"> 982</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-983"><a href="#BigQuery.Generator-983"><span class="linenos"> 983</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-984"><a href="#BigQuery.Generator-984"><span class="linenos"> 984</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-985"><a href="#BigQuery.Generator-985"><span class="linenos"> 985</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-986"><a href="#BigQuery.Generator-986"><span class="linenos"> 986</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-987"><a href="#BigQuery.Generator-987"><span class="linenos"> 987</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-988"><a href="#BigQuery.Generator-988"><span class="linenos"> 988</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-989"><a href="#BigQuery.Generator-989"><span class="linenos"> 989</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UUID</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-990"><a href="#BigQuery.Generator-990"><span class="linenos"> 990</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-991"><a href="#BigQuery.Generator-991"><span class="linenos"> 991</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-992"><a href="#BigQuery.Generator-992"><span class="linenos"> 992</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-993"><a href="#BigQuery.Generator-993"><span class="linenos"> 993</span></a> <span class="p">}</span> +</span><span id="BigQuery.Generator-994"><a href="#BigQuery.Generator-994"><span class="linenos"> 994</span></a> +</span><span id="BigQuery.Generator-995"><a href="#BigQuery.Generator-995"><span class="linenos"> 995</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Generator-996"><a href="#BigQuery.Generator-996"><span class="linenos"> 996</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="BigQuery.Generator-997"><a href="#BigQuery.Generator-997"><span class="linenos"> 997</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="BigQuery.Generator-998"><a href="#BigQuery.Generator-998"><span class="linenos"> 998</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="BigQuery.Generator-999"><a href="#BigQuery.Generator-999"><span class="linenos"> 999</span></a> <span class="p">}</span> +</span><span id="BigQuery.Generator-1000"><a href="#BigQuery.Generator-1000"><span class="linenos">1000</span></a> +</span><span id="BigQuery.Generator-1001"><a href="#BigQuery.Generator-1001"><span class="linenos">1001</span></a> <span class="c1"># WINDOW comes after QUALIFY</span> +</span><span id="BigQuery.Generator-1002"><a href="#BigQuery.Generator-1002"><span class="linenos">1002</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#window_clause</span> +</span><span id="BigQuery.Generator-1003"><a href="#BigQuery.Generator-1003"><span class="linenos">1003</span></a> <span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Generator-1004"><a href="#BigQuery.Generator-1004"><span class="linenos">1004</span></a> <span class="s2">"qualify"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"qualify"</span><span class="p">],</span> +</span><span id="BigQuery.Generator-1005"><a href="#BigQuery.Generator-1005"><span class="linenos">1005</span></a> <span class="s2">"windows"</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">AFTER_HAVING_MODIFIER_TRANSFORMS</span><span class="p">[</span><span class="s2">"windows"</span><span class="p">],</span> +</span><span id="BigQuery.Generator-1006"><a href="#BigQuery.Generator-1006"><span class="linenos">1006</span></a> <span class="p">}</span> +</span><span id="BigQuery.Generator-1007"><a href="#BigQuery.Generator-1007"><span class="linenos">1007</span></a> +</span><span id="BigQuery.Generator-1008"><a href="#BigQuery.Generator-1008"><span class="linenos">1008</span></a> <span class="c1"># from: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords</span> +</span><span id="BigQuery.Generator-1009"><a href="#BigQuery.Generator-1009"><span class="linenos">1009</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Generator-1010"><a href="#BigQuery.Generator-1010"><span class="linenos">1010</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1011"><a href="#BigQuery.Generator-1011"><span class="linenos">1011</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1012"><a href="#BigQuery.Generator-1012"><span class="linenos">1012</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1013"><a href="#BigQuery.Generator-1013"><span class="linenos">1013</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1014"><a href="#BigQuery.Generator-1014"><span class="linenos">1014</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1015"><a href="#BigQuery.Generator-1015"><span class="linenos">1015</span></a> <span class="s2">"asc"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1016"><a href="#BigQuery.Generator-1016"><span class="linenos">1016</span></a> <span class="s2">"assert_rows_modified"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1017"><a href="#BigQuery.Generator-1017"><span class="linenos">1017</span></a> <span class="s2">"at"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1018"><a href="#BigQuery.Generator-1018"><span class="linenos">1018</span></a> <span class="s2">"between"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1019"><a href="#BigQuery.Generator-1019"><span class="linenos">1019</span></a> <span class="s2">"by"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1020"><a href="#BigQuery.Generator-1020"><span class="linenos">1020</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1021"><a href="#BigQuery.Generator-1021"><span class="linenos">1021</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1022"><a href="#BigQuery.Generator-1022"><span class="linenos">1022</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1023"><a href="#BigQuery.Generator-1023"><span class="linenos">1023</span></a> <span class="s2">"contains"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1024"><a href="#BigQuery.Generator-1024"><span class="linenos">1024</span></a> <span class="s2">"create"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1025"><a href="#BigQuery.Generator-1025"><span class="linenos">1025</span></a> <span class="s2">"cross"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1026"><a href="#BigQuery.Generator-1026"><span class="linenos">1026</span></a> <span class="s2">"cube"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1027"><a href="#BigQuery.Generator-1027"><span class="linenos">1027</span></a> <span class="s2">"current"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1028"><a href="#BigQuery.Generator-1028"><span class="linenos">1028</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1029"><a href="#BigQuery.Generator-1029"><span class="linenos">1029</span></a> <span class="s2">"define"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1030"><a href="#BigQuery.Generator-1030"><span class="linenos">1030</span></a> <span class="s2">"desc"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1031"><a href="#BigQuery.Generator-1031"><span class="linenos">1031</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1032"><a href="#BigQuery.Generator-1032"><span class="linenos">1032</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1033"><a href="#BigQuery.Generator-1033"><span class="linenos">1033</span></a> <span class="s2">"end"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1034"><a href="#BigQuery.Generator-1034"><span class="linenos">1034</span></a> <span class="s2">"enum"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1035"><a href="#BigQuery.Generator-1035"><span class="linenos">1035</span></a> <span class="s2">"escape"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1036"><a href="#BigQuery.Generator-1036"><span class="linenos">1036</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1037"><a href="#BigQuery.Generator-1037"><span class="linenos">1037</span></a> <span class="s2">"exclude"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1038"><a href="#BigQuery.Generator-1038"><span class="linenos">1038</span></a> <span class="s2">"exists"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1039"><a href="#BigQuery.Generator-1039"><span class="linenos">1039</span></a> <span class="s2">"extract"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1040"><a href="#BigQuery.Generator-1040"><span class="linenos">1040</span></a> <span class="s2">"false"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1041"><a href="#BigQuery.Generator-1041"><span class="linenos">1041</span></a> <span class="s2">"fetch"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1042"><a href="#BigQuery.Generator-1042"><span class="linenos">1042</span></a> <span class="s2">"following"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1043"><a href="#BigQuery.Generator-1043"><span class="linenos">1043</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1044"><a href="#BigQuery.Generator-1044"><span class="linenos">1044</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1045"><a href="#BigQuery.Generator-1045"><span class="linenos">1045</span></a> <span class="s2">"full"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1046"><a href="#BigQuery.Generator-1046"><span class="linenos">1046</span></a> <span class="s2">"group"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1047"><a href="#BigQuery.Generator-1047"><span class="linenos">1047</span></a> <span class="s2">"grouping"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1048"><a href="#BigQuery.Generator-1048"><span class="linenos">1048</span></a> <span class="s2">"groups"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1049"><a href="#BigQuery.Generator-1049"><span class="linenos">1049</span></a> <span class="s2">"hash"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1050"><a href="#BigQuery.Generator-1050"><span class="linenos">1050</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1051"><a href="#BigQuery.Generator-1051"><span class="linenos">1051</span></a> <span class="s2">"if"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1052"><a href="#BigQuery.Generator-1052"><span class="linenos">1052</span></a> <span class="s2">"ignore"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1053"><a href="#BigQuery.Generator-1053"><span class="linenos">1053</span></a> <span class="s2">"in"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1054"><a href="#BigQuery.Generator-1054"><span class="linenos">1054</span></a> <span class="s2">"inner"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1055"><a href="#BigQuery.Generator-1055"><span class="linenos">1055</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1056"><a href="#BigQuery.Generator-1056"><span class="linenos">1056</span></a> <span class="s2">"interval"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1057"><a href="#BigQuery.Generator-1057"><span class="linenos">1057</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1058"><a href="#BigQuery.Generator-1058"><span class="linenos">1058</span></a> <span class="s2">"is"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1059"><a href="#BigQuery.Generator-1059"><span class="linenos">1059</span></a> <span class="s2">"join"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1060"><a href="#BigQuery.Generator-1060"><span class="linenos">1060</span></a> <span class="s2">"lateral"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1061"><a href="#BigQuery.Generator-1061"><span class="linenos">1061</span></a> <span class="s2">"left"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1062"><a href="#BigQuery.Generator-1062"><span class="linenos">1062</span></a> <span class="s2">"like"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1063"><a href="#BigQuery.Generator-1063"><span class="linenos">1063</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1064"><a href="#BigQuery.Generator-1064"><span class="linenos">1064</span></a> <span class="s2">"lookup"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1065"><a href="#BigQuery.Generator-1065"><span class="linenos">1065</span></a> <span class="s2">"merge"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1066"><a href="#BigQuery.Generator-1066"><span class="linenos">1066</span></a> <span class="s2">"natural"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1067"><a href="#BigQuery.Generator-1067"><span class="linenos">1067</span></a> <span class="s2">"new"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1068"><a href="#BigQuery.Generator-1068"><span class="linenos">1068</span></a> <span class="s2">"no"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1069"><a href="#BigQuery.Generator-1069"><span class="linenos">1069</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1070"><a href="#BigQuery.Generator-1070"><span class="linenos">1070</span></a> <span class="s2">"null"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1071"><a href="#BigQuery.Generator-1071"><span class="linenos">1071</span></a> <span class="s2">"nulls"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1072"><a href="#BigQuery.Generator-1072"><span class="linenos">1072</span></a> <span class="s2">"of"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1073"><a href="#BigQuery.Generator-1073"><span class="linenos">1073</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1074"><a href="#BigQuery.Generator-1074"><span class="linenos">1074</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1075"><a href="#BigQuery.Generator-1075"><span class="linenos">1075</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1076"><a href="#BigQuery.Generator-1076"><span class="linenos">1076</span></a> <span class="s2">"outer"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1077"><a href="#BigQuery.Generator-1077"><span class="linenos">1077</span></a> <span class="s2">"over"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1078"><a href="#BigQuery.Generator-1078"><span class="linenos">1078</span></a> <span class="s2">"partition"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1079"><a href="#BigQuery.Generator-1079"><span class="linenos">1079</span></a> <span class="s2">"preceding"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1080"><a href="#BigQuery.Generator-1080"><span class="linenos">1080</span></a> <span class="s2">"proto"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1081"><a href="#BigQuery.Generator-1081"><span class="linenos">1081</span></a> <span class="s2">"qualify"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1082"><a href="#BigQuery.Generator-1082"><span class="linenos">1082</span></a> <span class="s2">"range"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1083"><a href="#BigQuery.Generator-1083"><span class="linenos">1083</span></a> <span class="s2">"recursive"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1084"><a href="#BigQuery.Generator-1084"><span class="linenos">1084</span></a> <span class="s2">"respect"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1085"><a href="#BigQuery.Generator-1085"><span class="linenos">1085</span></a> <span class="s2">"right"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1086"><a href="#BigQuery.Generator-1086"><span class="linenos">1086</span></a> <span class="s2">"rollup"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1087"><a href="#BigQuery.Generator-1087"><span class="linenos">1087</span></a> <span class="s2">"rows"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1088"><a href="#BigQuery.Generator-1088"><span class="linenos">1088</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1089"><a href="#BigQuery.Generator-1089"><span class="linenos">1089</span></a> <span class="s2">"set"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1090"><a href="#BigQuery.Generator-1090"><span class="linenos">1090</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1091"><a href="#BigQuery.Generator-1091"><span class="linenos">1091</span></a> <span class="s2">"struct"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1092"><a href="#BigQuery.Generator-1092"><span class="linenos">1092</span></a> <span class="s2">"tablesample"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1093"><a href="#BigQuery.Generator-1093"><span class="linenos">1093</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1094"><a href="#BigQuery.Generator-1094"><span class="linenos">1094</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1095"><a href="#BigQuery.Generator-1095"><span class="linenos">1095</span></a> <span class="s2">"treat"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1096"><a href="#BigQuery.Generator-1096"><span class="linenos">1096</span></a> <span class="s2">"true"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1097"><a href="#BigQuery.Generator-1097"><span class="linenos">1097</span></a> <span class="s2">"unbounded"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1098"><a href="#BigQuery.Generator-1098"><span class="linenos">1098</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1099"><a href="#BigQuery.Generator-1099"><span class="linenos">1099</span></a> <span class="s2">"unnest"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1100"><a href="#BigQuery.Generator-1100"><span class="linenos">1100</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1101"><a href="#BigQuery.Generator-1101"><span class="linenos">1101</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1102"><a href="#BigQuery.Generator-1102"><span class="linenos">1102</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1103"><a href="#BigQuery.Generator-1103"><span class="linenos">1103</span></a> <span class="s2">"window"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1104"><a href="#BigQuery.Generator-1104"><span class="linenos">1104</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1105"><a href="#BigQuery.Generator-1105"><span class="linenos">1105</span></a> <span class="s2">"within"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1106"><a href="#BigQuery.Generator-1106"><span class="linenos">1106</span></a> <span class="p">}</span> +</span><span id="BigQuery.Generator-1107"><a href="#BigQuery.Generator-1107"><span class="linenos">1107</span></a> +</span><span id="BigQuery.Generator-1108"><a href="#BigQuery.Generator-1108"><span class="linenos">1108</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1109"><a href="#BigQuery.Generator-1109"><span class="linenos">1109</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator-1110"><a href="#BigQuery.Generator-1110"><span class="linenos">1110</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="BigQuery.Generator-1111"><a href="#BigQuery.Generator-1111"><span class="linenos">1111</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery.Generator-1112"><a href="#BigQuery.Generator-1112"><span class="linenos">1112</span></a> <span class="s2">"MOD"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1113"><a href="#BigQuery.Generator-1113"><span class="linenos">1113</span></a> <span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <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">Paren</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1114"><a href="#BigQuery.Generator-1114"><span class="linenos">1114</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</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="k">else</span> <span class="n">expr</span><span class="p">,</span> +</span><span id="BigQuery.Generator-1115"><a href="#BigQuery.Generator-1115"><span class="linenos">1115</span></a> <span class="p">)</span> +</span><span id="BigQuery.Generator-1116"><a href="#BigQuery.Generator-1116"><span class="linenos">1116</span></a> +</span><span id="BigQuery.Generator-1117"><a href="#BigQuery.Generator-1117"><span class="linenos">1117</span></a> <span class="k">def</span> <span class="nf">column_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1118"><a href="#BigQuery.Generator-1118"><span class="linenos">1118</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_column"</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1119"><a href="#BigQuery.Generator-1119"><span class="linenos">1119</span></a> <span class="c1"># If a column reference is of the form `dataset.table`.name, we need</span> +</span><span id="BigQuery.Generator-1120"><a href="#BigQuery.Generator-1120"><span class="linenos">1120</span></a> <span class="c1"># to preserve the quoted table path, otherwise the reference breaks</span> +</span><span id="BigQuery.Generator-1121"><a href="#BigQuery.Generator-1121"><span class="linenos">1121</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> +</span><span id="BigQuery.Generator-1122"><a href="#BigQuery.Generator-1122"><span class="linenos">1122</span></a> <span class="n">table_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</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="BigQuery.Generator-1123"><a href="#BigQuery.Generator-1123"><span class="linenos">1123</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_path</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator-1124"><a href="#BigQuery.Generator-1124"><span class="linenos">1124</span></a> +</span><span id="BigQuery.Generator-1125"><a href="#BigQuery.Generator-1125"><span class="linenos">1125</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">column_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1126"><a href="#BigQuery.Generator-1126"><span class="linenos">1126</span></a> +</span><span id="BigQuery.Generator-1127"><a href="#BigQuery.Generator-1127"><span class="linenos">1127</span></a> <span class="k">def</span> <span class="nf">table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1128"><a href="#BigQuery.Generator-1128"><span class="linenos">1128</span></a> <span class="c1"># Depending on the context, `x.y` may not resolve to the same data source as `x`.`y`, so</span> +</span><span id="BigQuery.Generator-1129"><a href="#BigQuery.Generator-1129"><span class="linenos">1129</span></a> <span class="c1"># we need to make sure the correct quoting is used in each case.</span> +</span><span id="BigQuery.Generator-1130"><a href="#BigQuery.Generator-1130"><span class="linenos">1130</span></a> <span class="c1">#</span> +</span><span id="BigQuery.Generator-1131"><a href="#BigQuery.Generator-1131"><span class="linenos">1131</span></a> <span class="c1"># For example, if there is a CTE x that clashes with a schema name, then the former will</span> +</span><span id="BigQuery.Generator-1132"><a href="#BigQuery.Generator-1132"><span class="linenos">1132</span></a> <span class="c1"># return the table y in that schema, whereas the latter will return the CTE's y column:</span> +</span><span id="BigQuery.Generator-1133"><a href="#BigQuery.Generator-1133"><span class="linenos">1133</span></a> <span class="c1">#</span> +</span><span id="BigQuery.Generator-1134"><a href="#BigQuery.Generator-1134"><span class="linenos">1134</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x.y` -> cross join</span> +</span><span id="BigQuery.Generator-1135"><a href="#BigQuery.Generator-1135"><span class="linenos">1135</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x`.`y` -> implicit unnest</span> +</span><span id="BigQuery.Generator-1136"><a href="#BigQuery.Generator-1136"><span class="linenos">1136</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_table"</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1137"><a href="#BigQuery.Generator-1137"><span class="linenos">1137</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1138"><a href="#BigQuery.Generator-1138"><span class="linenos">1138</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="BigQuery.Generator-1139"><a href="#BigQuery.Generator-1139"><span class="linenos">1139</span></a> +</span><span id="BigQuery.Generator-1140"><a href="#BigQuery.Generator-1140"><span class="linenos">1140</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">table_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1141"><a href="#BigQuery.Generator-1141"><span class="linenos">1141</span></a> +</span><span id="BigQuery.Generator-1142"><a href="#BigQuery.Generator-1142"><span class="linenos">1142</span></a> <span class="k">def</span> <span class="nf">timetostr_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1143"><a href="#BigQuery.Generator-1143"><span class="linenos">1143</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator-1144"><a href="#BigQuery.Generator-1144"><span class="linenos">1144</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">TsOrDsToDatetime</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1145"><a href="#BigQuery.Generator-1145"><span class="linenos">1145</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATETIME"</span> +</span><span id="BigQuery.Generator-1146"><a href="#BigQuery.Generator-1146"><span class="linenos">1146</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">TsOrDsToTimestamp</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1147"><a href="#BigQuery.Generator-1147"><span class="linenos">1147</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_TIMESTAMP"</span> +</span><span id="BigQuery.Generator-1148"><a href="#BigQuery.Generator-1148"><span class="linenos">1148</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1149"><a href="#BigQuery.Generator-1149"><span class="linenos">1149</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATE"</span> +</span><span id="BigQuery.Generator-1150"><a href="#BigQuery.Generator-1150"><span class="linenos">1150</span></a> +</span><span id="BigQuery.Generator-1151"><a href="#BigQuery.Generator-1151"><span class="linenos">1151</span></a> <span class="n">time_expr</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="BigQuery.Generator-1152"><a href="#BigQuery.Generator-1152"><span class="linenos">1152</span></a> <span class="n">this</span> +</span><span id="BigQuery.Generator-1153"><a href="#BigQuery.Generator-1153"><span class="linenos">1153</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="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">))</span> +</span><span id="BigQuery.Generator-1154"><a href="#BigQuery.Generator-1154"><span class="linenos">1154</span></a> <span class="k">else</span> <span class="n">expression</span> +</span><span id="BigQuery.Generator-1155"><a href="#BigQuery.Generator-1155"><span class="linenos">1155</span></a> <span class="p">)</span> +</span><span id="BigQuery.Generator-1156"><a href="#BigQuery.Generator-1156"><span class="linenos">1156</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">time_expr</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1157"><a href="#BigQuery.Generator-1157"><span class="linenos">1157</span></a> +</span><span id="BigQuery.Generator-1158"><a href="#BigQuery.Generator-1158"><span class="linenos">1158</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1159"><a href="#BigQuery.Generator-1159"><span class="linenos">1159</span></a> <span class="c1"># Operands of = cannot be NULL in BigQuery</span> +</span><span id="BigQuery.Generator-1160"><a href="#BigQuery.Generator-1160"><span class="linenos">1160</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">right</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1161"><a href="#BigQuery.Generator-1161"><span class="linenos">1161</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1162"><a href="#BigQuery.Generator-1162"><span class="linenos">1162</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> +</span><span id="BigQuery.Generator-1163"><a href="#BigQuery.Generator-1163"><span class="linenos">1163</span></a> +</span><span id="BigQuery.Generator-1164"><a href="#BigQuery.Generator-1164"><span class="linenos">1164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1165"><a href="#BigQuery.Generator-1165"><span class="linenos">1165</span></a> +</span><span id="BigQuery.Generator-1166"><a href="#BigQuery.Generator-1166"><span class="linenos">1166</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1167"><a href="#BigQuery.Generator-1167"><span class="linenos">1167</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> +</span><span id="BigQuery.Generator-1168"><a href="#BigQuery.Generator-1168"><span class="linenos">1168</span></a> +</span><span id="BigQuery.Generator-1169"><a href="#BigQuery.Generator-1169"><span class="linenos">1169</span></a> <span class="c1"># BigQuery allows CAST(.. AS {STRING|TIMESTAMP} [FORMAT <fmt> [AT TIME ZONE <tz>]]).</span> +</span><span id="BigQuery.Generator-1170"><a href="#BigQuery.Generator-1170"><span class="linenos">1170</span></a> <span class="c1"># Only the TIMESTAMP one should use the below conversion, when AT TIME ZONE is included.</span> +</span><span id="BigQuery.Generator-1171"><a href="#BigQuery.Generator-1171"><span class="linenos">1171</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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1172"><a href="#BigQuery.Generator-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery.Generator-1173"><a href="#BigQuery.Generator-1173"><span class="linenos">1173</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">))</span> +</span><span id="BigQuery.Generator-1174"><a href="#BigQuery.Generator-1174"><span class="linenos">1174</span></a> <span class="p">)</span> +</span><span id="BigQuery.Generator-1175"><a href="#BigQuery.Generator-1175"><span class="linenos">1175</span></a> +</span><span id="BigQuery.Generator-1176"><a href="#BigQuery.Generator-1176"><span class="linenos">1176</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">attimezone_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1177"><a href="#BigQuery.Generator-1177"><span class="linenos">1177</span></a> +</span><span id="BigQuery.Generator-1178"><a href="#BigQuery.Generator-1178"><span class="linenos">1178</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1179"><a href="#BigQuery.Generator-1179"><span class="linenos">1179</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"SAFE_"</span><span class="p">)</span> </span><span id="BigQuery.Generator-1180"><a href="#BigQuery.Generator-1180"><span class="linenos">1180</span></a> -</span><span id="BigQuery.Generator-1181"><a href="#BigQuery.Generator-1181"><span class="linenos">1181</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="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1182"><a href="#BigQuery.Generator-1182"><span class="linenos">1182</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="BigQuery.Generator-1183"><a href="#BigQuery.Generator-1183"><span class="linenos">1183</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1184"><a href="#BigQuery.Generator-1184"><span class="linenos">1184</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> -</span><span id="BigQuery.Generator-1185"><a href="#BigQuery.Generator-1185"><span class="linenos">1185</span></a> -</span><span id="BigQuery.Generator-1186"><a href="#BigQuery.Generator-1186"><span class="linenos">1186</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1187"><a href="#BigQuery.Generator-1187"><span class="linenos">1187</span></a> -</span><span id="BigQuery.Generator-1188"><a href="#BigQuery.Generator-1188"><span class="linenos">1188</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">and</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</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">TEXT_TYPES</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1189"><a href="#BigQuery.Generator-1189"><span class="linenos">1189</span></a> <span class="c1"># BQ doesn't support bracket syntax with string values for structs</span> -</span><span id="BigQuery.Generator-1190"><a href="#BigQuery.Generator-1190"><span class="linenos">1190</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator-1181"><a href="#BigQuery.Generator-1181"><span class="linenos">1181</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1182"><a href="#BigQuery.Generator-1182"><span class="linenos">1182</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator-1183"><a href="#BigQuery.Generator-1183"><span class="linenos">1183</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery.Generator-1184"><a href="#BigQuery.Generator-1184"><span class="linenos">1184</span></a> +</span><span id="BigQuery.Generator-1185"><a href="#BigQuery.Generator-1185"><span class="linenos">1185</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="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1186"><a href="#BigQuery.Generator-1186"><span class="linenos">1186</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="BigQuery.Generator-1187"><a href="#BigQuery.Generator-1187"><span class="linenos">1187</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1188"><a href="#BigQuery.Generator-1188"><span class="linenos">1188</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="BigQuery.Generator-1189"><a href="#BigQuery.Generator-1189"><span class="linenos">1189</span></a> +</span><span id="BigQuery.Generator-1190"><a href="#BigQuery.Generator-1190"><span class="linenos">1190</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> </span><span id="BigQuery.Generator-1191"><a href="#BigQuery.Generator-1191"><span class="linenos">1191</span></a> -</span><span id="BigQuery.Generator-1192"><a href="#BigQuery.Generator-1192"><span class="linenos">1192</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1193"><a href="#BigQuery.Generator-1193"><span class="linenos">1193</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1194"><a href="#BigQuery.Generator-1194"><span class="linenos">1194</span></a> -</span><span id="BigQuery.Generator-1195"><a href="#BigQuery.Generator-1195"><span class="linenos">1195</span></a> <span class="k">if</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1196"><a href="#BigQuery.Generator-1196"><span class="linenos">1196</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OFFSET(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="BigQuery.Generator-1197"><a href="#BigQuery.Generator-1197"><span class="linenos">1197</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1198"><a href="#BigQuery.Generator-1198"><span class="linenos">1198</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ORDINAL(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="BigQuery.Generator-1199"><a href="#BigQuery.Generator-1199"><span class="linenos">1199</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1200"><a href="#BigQuery.Generator-1200"><span class="linenos">1200</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported array offset: </span><span class="si">{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1201"><a href="#BigQuery.Generator-1201"><span class="linenos">1201</span></a> -</span><span id="BigQuery.Generator-1202"><a href="#BigQuery.Generator-1202"><span class="linenos">1202</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1203"><a href="#BigQuery.Generator-1203"><span class="linenos">1203</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"SAFE_</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator-1204"><a href="#BigQuery.Generator-1204"><span class="linenos">1204</span></a> -</span><span id="BigQuery.Generator-1205"><a href="#BigQuery.Generator-1205"><span class="linenos">1205</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> -</span><span id="BigQuery.Generator-1206"><a href="#BigQuery.Generator-1206"><span class="linenos">1206</span></a> -</span><span id="BigQuery.Generator-1207"><a href="#BigQuery.Generator-1207"><span class="linenos">1207</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1208"><a href="#BigQuery.Generator-1208"><span class="linenos">1208</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1209"><a href="#BigQuery.Generator-1209"><span class="linenos">1209</span></a> -</span><span id="BigQuery.Generator-1210"><a href="#BigQuery.Generator-1210"><span class="linenos">1210</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1211"><a href="#BigQuery.Generator-1211"><span class="linenos">1211</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1212"><a href="#BigQuery.Generator-1212"><span class="linenos">1212</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"SYSTEM_TIME"</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1213"><a href="#BigQuery.Generator-1213"><span class="linenos">1213</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">version_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="BigQuery.Generator-1214"><a href="#BigQuery.Generator-1214"><span class="linenos">1214</span></a> -</span><span id="BigQuery.Generator-1215"><a href="#BigQuery.Generator-1215"><span class="linenos">1215</span></a> <span class="k">def</span> <span class="nf">contains_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Contains</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-1216"><a href="#BigQuery.Generator-1216"><span class="linenos">1216</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery.Generator-1217"><a href="#BigQuery.Generator-1217"><span class="linenos">1217</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="BigQuery.Generator-1192"><a href="#BigQuery.Generator-1192"><span class="linenos">1192</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">and</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</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">TEXT_TYPES</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1193"><a href="#BigQuery.Generator-1193"><span class="linenos">1193</span></a> <span class="c1"># BQ doesn't support bracket syntax with string values for structs</span> +</span><span id="BigQuery.Generator-1194"><a href="#BigQuery.Generator-1194"><span class="linenos">1194</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator-1195"><a href="#BigQuery.Generator-1195"><span class="linenos">1195</span></a> +</span><span id="BigQuery.Generator-1196"><a href="#BigQuery.Generator-1196"><span class="linenos">1196</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1197"><a href="#BigQuery.Generator-1197"><span class="linenos">1197</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1198"><a href="#BigQuery.Generator-1198"><span class="linenos">1198</span></a> +</span><span id="BigQuery.Generator-1199"><a href="#BigQuery.Generator-1199"><span class="linenos">1199</span></a> <span class="k">if</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1200"><a href="#BigQuery.Generator-1200"><span class="linenos">1200</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OFFSET(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="BigQuery.Generator-1201"><a href="#BigQuery.Generator-1201"><span class="linenos">1201</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1202"><a href="#BigQuery.Generator-1202"><span class="linenos">1202</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ORDINAL(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="BigQuery.Generator-1203"><a href="#BigQuery.Generator-1203"><span class="linenos">1203</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1204"><a href="#BigQuery.Generator-1204"><span class="linenos">1204</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported array offset: </span><span class="si">{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1205"><a href="#BigQuery.Generator-1205"><span class="linenos">1205</span></a> +</span><span id="BigQuery.Generator-1206"><a href="#BigQuery.Generator-1206"><span class="linenos">1206</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1207"><a href="#BigQuery.Generator-1207"><span class="linenos">1207</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"SAFE_</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator-1208"><a href="#BigQuery.Generator-1208"><span class="linenos">1208</span></a> +</span><span id="BigQuery.Generator-1209"><a href="#BigQuery.Generator-1209"><span class="linenos">1209</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="BigQuery.Generator-1210"><a href="#BigQuery.Generator-1210"><span class="linenos">1210</span></a> +</span><span id="BigQuery.Generator-1211"><a href="#BigQuery.Generator-1211"><span class="linenos">1211</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1212"><a href="#BigQuery.Generator-1212"><span class="linenos">1212</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1213"><a href="#BigQuery.Generator-1213"><span class="linenos">1213</span></a> +</span><span id="BigQuery.Generator-1214"><a href="#BigQuery.Generator-1214"><span class="linenos">1214</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1215"><a href="#BigQuery.Generator-1215"><span class="linenos">1215</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1216"><a href="#BigQuery.Generator-1216"><span class="linenos">1216</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"SYSTEM_TIME"</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1217"><a href="#BigQuery.Generator-1217"><span class="linenos">1217</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">version_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="BigQuery.Generator-1218"><a href="#BigQuery.Generator-1218"><span class="linenos">1218</span></a> -</span><span id="BigQuery.Generator-1219"><a href="#BigQuery.Generator-1219"><span class="linenos">1219</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">Lower</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">):</span> -</span><span id="BigQuery.Generator-1220"><a href="#BigQuery.Generator-1220"><span class="linenos">1220</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="BigQuery.Generator-1221"><a href="#BigQuery.Generator-1221"><span class="linenos">1221</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator-1219"><a href="#BigQuery.Generator-1219"><span class="linenos">1219</span></a> <span class="k">def</span> <span class="nf">contains_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Contains</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-1220"><a href="#BigQuery.Generator-1220"><span class="linenos">1220</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator-1221"><a href="#BigQuery.Generator-1221"><span class="linenos">1221</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> </span><span id="BigQuery.Generator-1222"><a href="#BigQuery.Generator-1222"><span class="linenos">1222</span></a> -</span><span id="BigQuery.Generator-1223"><a href="#BigQuery.Generator-1223"><span class="linenos">1223</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONTAINS_SUBSTR"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> +</span><span id="BigQuery.Generator-1223"><a href="#BigQuery.Generator-1223"><span class="linenos">1223</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">Lower</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">):</span> +</span><span id="BigQuery.Generator-1224"><a href="#BigQuery.Generator-1224"><span class="linenos">1224</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="BigQuery.Generator-1225"><a href="#BigQuery.Generator-1225"><span class="linenos">1225</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator-1226"><a href="#BigQuery.Generator-1226"><span class="linenos">1226</span></a> +</span><span id="BigQuery.Generator-1227"><a href="#BigQuery.Generator-1227"><span class="linenos">1227</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONTAINS_SUBSTR"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> </span></pre></div> @@ -4928,7 +4955,7 @@ Default: True</li> <div class="attr variable"> <span class="name">SUPPORTED_JSON_PATH_PARTS</span> = <input id="BigQuery.Generator.SUPPORTED_JSON_PATH_PARTS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="BigQuery.Generator.SUPPORTED_JSON_PATH_PARTS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>, <class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>}</span> + <label class="view-value-button pdoc-button" for="BigQuery.Generator.SUPPORTED_JSON_PATH_PARTS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>, <class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>, <class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>}</span> </div> @@ -4979,7 +5006,7 @@ Default: True</li> <div class="attr variable"> <span class="name">RESERVED_KEYWORDS</span> = <input id="BigQuery.Generator.RESERVED_KEYWORDS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="BigQuery.Generator.RESERVED_KEYWORDS-view-value"></label><span class="default_value">{'else', 'recursive', 'right', 'unbounded', 'following', 'range', 'like', 'with', 'on', 'case', 'true', 'is', 'natural', 'tablesample', 'as', 'limit', 'over', 'respect', 'union', 'rollup', 'at', 'group', 'of', 'nulls', 'or', 'and', 'escape', 'new', 'collate', 'all', 'struct', 'ignore', 'except', 'merge', 'full', 'cube', 'null', 'where', 'assert_rows_modified', 'partition', 'exclude', 'lookup', 'extract', 'fetch', 'default', 'using', 'by', 'distinct', 'outer', 'not', 'treat', 'qualify', 'exists', 'preceding', 'in', 'any', 'cast', 'current', 'proto', 'array', 'having', 'groups', 'desc', 'for', 'inner', 'unnest', 'no', 'cross', 'left', 'define', 'within', 'some', 'between', 'into', 'rows', 'create', 'select', 'asc', 'enum', 'interval', 'join', 'false', 'if', 'from', 'to', 'end', 'hash', 'set', 'contains', 'when', 'then', 'intersect', 'grouping', 'order', 'window', 'lateral'}</span> + <label class="view-value-button pdoc-button" for="BigQuery.Generator.RESERVED_KEYWORDS-view-value"></label><span class="default_value">{'not', 'end', 'ignore', 'proto', 'respect', 'into', 'limit', 'define', 'assert_rows_modified', 'groups', 'tablesample', 'to', 'asc', 'if', 'enum', 'default', 'grouping', 'set', 'case', 'array', 'nulls', 'order', 'false', 'merge', 'exclude', 'null', 'join', 'cast', 'rollup', 'hash', 'inner', 'range', 'like', 'desc', 'escape', 'else', 'recursive', 'on', 'of', 'struct', 'where', 'treat', 'select', 'from', 'when', 'left', 'following', 'cross', 'new', 'between', 'preceding', 'exists', 'no', 'create', 'natural', 'contains', 'as', 'at', 'union', 'rows', 'then', 'within', 'having', 'any', 'cube', 'current', 'using', 'lookup', 'intersect', 'unbounded', 'and', 'by', 'right', 'collate', 'full', 'partition', 'window', 'fetch', 'is', 'interval', 'extract', 'for', 'unnest', 'true', 'all', 'distinct', 'or', 'some', 'over', 'qualify', 'in', 'lateral', 'group', 'except', 'with', 'outer'}</span> </div> @@ -4999,14 +5026,14 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.mod_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.mod_sql-1104"><a href="#BigQuery.Generator.mod_sql-1104"><span class="linenos">1104</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.mod_sql-1105"><a href="#BigQuery.Generator.mod_sql-1105"><span class="linenos">1105</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery.Generator.mod_sql-1106"><a href="#BigQuery.Generator.mod_sql-1106"><span class="linenos">1106</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="BigQuery.Generator.mod_sql-1107"><a href="#BigQuery.Generator.mod_sql-1107"><span class="linenos">1107</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery.Generator.mod_sql-1108"><a href="#BigQuery.Generator.mod_sql-1108"><span class="linenos">1108</span></a> <span class="s2">"MOD"</span><span class="p">,</span> -</span><span id="BigQuery.Generator.mod_sql-1109"><a href="#BigQuery.Generator.mod_sql-1109"><span class="linenos">1109</span></a> <span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <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">Paren</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> -</span><span id="BigQuery.Generator.mod_sql-1110"><a href="#BigQuery.Generator.mod_sql-1110"><span class="linenos">1110</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</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="k">else</span> <span class="n">expr</span><span class="p">,</span> -</span><span id="BigQuery.Generator.mod_sql-1111"><a href="#BigQuery.Generator.mod_sql-1111"><span class="linenos">1111</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.mod_sql-1108"><a href="#BigQuery.Generator.mod_sql-1108"><span class="linenos">1108</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.mod_sql-1109"><a href="#BigQuery.Generator.mod_sql-1109"><span class="linenos">1109</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator.mod_sql-1110"><a href="#BigQuery.Generator.mod_sql-1110"><span class="linenos">1110</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="BigQuery.Generator.mod_sql-1111"><a href="#BigQuery.Generator.mod_sql-1111"><span class="linenos">1111</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery.Generator.mod_sql-1112"><a href="#BigQuery.Generator.mod_sql-1112"><span class="linenos">1112</span></a> <span class="s2">"MOD"</span><span class="p">,</span> +</span><span id="BigQuery.Generator.mod_sql-1113"><a href="#BigQuery.Generator.mod_sql-1113"><span class="linenos">1113</span></a> <span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <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">Paren</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> +</span><span id="BigQuery.Generator.mod_sql-1114"><a href="#BigQuery.Generator.mod_sql-1114"><span class="linenos">1114</span></a> <span class="n">expr</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</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="k">else</span> <span class="n">expr</span><span class="p">,</span> +</span><span id="BigQuery.Generator.mod_sql-1115"><a href="#BigQuery.Generator.mod_sql-1115"><span class="linenos">1115</span></a> <span class="p">)</span> </span></pre></div> @@ -5024,15 +5051,15 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.column_parts"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.column_parts-1113"><a href="#BigQuery.Generator.column_parts-1113"><span class="linenos">1113</span></a> <span class="k">def</span> <span class="nf">column_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.column_parts-1114"><a href="#BigQuery.Generator.column_parts-1114"><span class="linenos">1114</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_column"</span><span class="p">):</span> -</span><span id="BigQuery.Generator.column_parts-1115"><a href="#BigQuery.Generator.column_parts-1115"><span class="linenos">1115</span></a> <span class="c1"># If a column reference is of the form `dataset.table`.name, we need</span> -</span><span id="BigQuery.Generator.column_parts-1116"><a href="#BigQuery.Generator.column_parts-1116"><span class="linenos">1116</span></a> <span class="c1"># to preserve the quoted table path, otherwise the reference breaks</span> -</span><span id="BigQuery.Generator.column_parts-1117"><a href="#BigQuery.Generator.column_parts-1117"><span class="linenos">1117</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> -</span><span id="BigQuery.Generator.column_parts-1118"><a href="#BigQuery.Generator.column_parts-1118"><span class="linenos">1118</span></a> <span class="n">table_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</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="BigQuery.Generator.column_parts-1119"><a href="#BigQuery.Generator.column_parts-1119"><span class="linenos">1119</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_path</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator.column_parts-1120"><a href="#BigQuery.Generator.column_parts-1120"><span class="linenos">1120</span></a> -</span><span id="BigQuery.Generator.column_parts-1121"><a href="#BigQuery.Generator.column_parts-1121"><span class="linenos">1121</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">column_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.column_parts-1117"><a href="#BigQuery.Generator.column_parts-1117"><span class="linenos">1117</span></a> <span class="k">def</span> <span class="nf">column_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.column_parts-1118"><a href="#BigQuery.Generator.column_parts-1118"><span class="linenos">1118</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_column"</span><span class="p">):</span> +</span><span id="BigQuery.Generator.column_parts-1119"><a href="#BigQuery.Generator.column_parts-1119"><span class="linenos">1119</span></a> <span class="c1"># If a column reference is of the form `dataset.table`.name, we need</span> +</span><span id="BigQuery.Generator.column_parts-1120"><a href="#BigQuery.Generator.column_parts-1120"><span class="linenos">1120</span></a> <span class="c1"># to preserve the quoted table path, otherwise the reference breaks</span> +</span><span id="BigQuery.Generator.column_parts-1121"><a href="#BigQuery.Generator.column_parts-1121"><span class="linenos">1121</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> +</span><span id="BigQuery.Generator.column_parts-1122"><a href="#BigQuery.Generator.column_parts-1122"><span class="linenos">1122</span></a> <span class="n">table_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</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="BigQuery.Generator.column_parts-1123"><a href="#BigQuery.Generator.column_parts-1123"><span class="linenos">1123</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table_path</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator.column_parts-1124"><a href="#BigQuery.Generator.column_parts-1124"><span class="linenos">1124</span></a> +</span><span id="BigQuery.Generator.column_parts-1125"><a href="#BigQuery.Generator.column_parts-1125"><span class="linenos">1125</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">column_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -5050,20 +5077,20 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.table_parts"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.table_parts-1123"><a href="#BigQuery.Generator.table_parts-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.table_parts-1124"><a href="#BigQuery.Generator.table_parts-1124"><span class="linenos">1124</span></a> <span class="c1"># Depending on the context, `x.y` may not resolve to the same data source as `x`.`y`, so</span> -</span><span id="BigQuery.Generator.table_parts-1125"><a href="#BigQuery.Generator.table_parts-1125"><span class="linenos">1125</span></a> <span class="c1"># we need to make sure the correct quoting is used in each case.</span> -</span><span id="BigQuery.Generator.table_parts-1126"><a href="#BigQuery.Generator.table_parts-1126"><span class="linenos">1126</span></a> <span class="c1">#</span> -</span><span id="BigQuery.Generator.table_parts-1127"><a href="#BigQuery.Generator.table_parts-1127"><span class="linenos">1127</span></a> <span class="c1"># For example, if there is a CTE x that clashes with a schema name, then the former will</span> -</span><span id="BigQuery.Generator.table_parts-1128"><a href="#BigQuery.Generator.table_parts-1128"><span class="linenos">1128</span></a> <span class="c1"># return the table y in that schema, whereas the latter will return the CTE's y column:</span> -</span><span id="BigQuery.Generator.table_parts-1129"><a href="#BigQuery.Generator.table_parts-1129"><span class="linenos">1129</span></a> <span class="c1">#</span> -</span><span id="BigQuery.Generator.table_parts-1130"><a href="#BigQuery.Generator.table_parts-1130"><span class="linenos">1130</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x.y` -> cross join</span> -</span><span id="BigQuery.Generator.table_parts-1131"><a href="#BigQuery.Generator.table_parts-1131"><span class="linenos">1131</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x`.`y` -> implicit unnest</span> -</span><span id="BigQuery.Generator.table_parts-1132"><a href="#BigQuery.Generator.table_parts-1132"><span class="linenos">1132</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_table"</span><span class="p">):</span> -</span><span id="BigQuery.Generator.table_parts-1133"><a href="#BigQuery.Generator.table_parts-1133"><span class="linenos">1133</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">)</span> -</span><span id="BigQuery.Generator.table_parts-1134"><a href="#BigQuery.Generator.table_parts-1134"><span class="linenos">1134</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="BigQuery.Generator.table_parts-1135"><a href="#BigQuery.Generator.table_parts-1135"><span class="linenos">1135</span></a> -</span><span id="BigQuery.Generator.table_parts-1136"><a href="#BigQuery.Generator.table_parts-1136"><span class="linenos">1136</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">table_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.table_parts-1127"><a href="#BigQuery.Generator.table_parts-1127"><span class="linenos">1127</span></a> <span class="k">def</span> <span class="nf">table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.table_parts-1128"><a href="#BigQuery.Generator.table_parts-1128"><span class="linenos">1128</span></a> <span class="c1"># Depending on the context, `x.y` may not resolve to the same data source as `x`.`y`, so</span> +</span><span id="BigQuery.Generator.table_parts-1129"><a href="#BigQuery.Generator.table_parts-1129"><span class="linenos">1129</span></a> <span class="c1"># we need to make sure the correct quoting is used in each case.</span> +</span><span id="BigQuery.Generator.table_parts-1130"><a href="#BigQuery.Generator.table_parts-1130"><span class="linenos">1130</span></a> <span class="c1">#</span> +</span><span id="BigQuery.Generator.table_parts-1131"><a href="#BigQuery.Generator.table_parts-1131"><span class="linenos">1131</span></a> <span class="c1"># For example, if there is a CTE x that clashes with a schema name, then the former will</span> +</span><span id="BigQuery.Generator.table_parts-1132"><a href="#BigQuery.Generator.table_parts-1132"><span class="linenos">1132</span></a> <span class="c1"># return the table y in that schema, whereas the latter will return the CTE's y column:</span> +</span><span id="BigQuery.Generator.table_parts-1133"><a href="#BigQuery.Generator.table_parts-1133"><span class="linenos">1133</span></a> <span class="c1">#</span> +</span><span id="BigQuery.Generator.table_parts-1134"><a href="#BigQuery.Generator.table_parts-1134"><span class="linenos">1134</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x.y` -> cross join</span> +</span><span id="BigQuery.Generator.table_parts-1135"><a href="#BigQuery.Generator.table_parts-1135"><span class="linenos">1135</span></a> <span class="c1"># - WITH x AS (SELECT [1, 2] AS y) SELECT * FROM x, `x`.`y` -> implicit unnest</span> +</span><span id="BigQuery.Generator.table_parts-1136"><a href="#BigQuery.Generator.table_parts-1136"><span class="linenos">1136</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted_table"</span><span class="p">):</span> +</span><span id="BigQuery.Generator.table_parts-1137"><a href="#BigQuery.Generator.table_parts-1137"><span class="linenos">1137</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">parts</span><span class="p">)</span> +</span><span id="BigQuery.Generator.table_parts-1138"><a href="#BigQuery.Generator.table_parts-1138"><span class="linenos">1138</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="BigQuery.Generator.table_parts-1139"><a href="#BigQuery.Generator.table_parts-1139"><span class="linenos">1139</span></a> +</span><span id="BigQuery.Generator.table_parts-1140"><a href="#BigQuery.Generator.table_parts-1140"><span class="linenos">1140</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">table_parts</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -5081,21 +5108,21 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.timetostr_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.timetostr_sql-1138"><a href="#BigQuery.Generator.timetostr_sql-1138"><span class="linenos">1138</span></a> <span class="k">def</span> <span class="nf">timetostr_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.timetostr_sql-1139"><a href="#BigQuery.Generator.timetostr_sql-1139"><span class="linenos">1139</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery.Generator.timetostr_sql-1140"><a href="#BigQuery.Generator.timetostr_sql-1140"><span class="linenos">1140</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">TsOrDsToDatetime</span><span class="p">):</span> -</span><span id="BigQuery.Generator.timetostr_sql-1141"><a href="#BigQuery.Generator.timetostr_sql-1141"><span class="linenos">1141</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATETIME"</span> -</span><span id="BigQuery.Generator.timetostr_sql-1142"><a href="#BigQuery.Generator.timetostr_sql-1142"><span class="linenos">1142</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">TsOrDsToTimestamp</span><span class="p">):</span> -</span><span id="BigQuery.Generator.timetostr_sql-1143"><a href="#BigQuery.Generator.timetostr_sql-1143"><span class="linenos">1143</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_TIMESTAMP"</span> -</span><span id="BigQuery.Generator.timetostr_sql-1144"><a href="#BigQuery.Generator.timetostr_sql-1144"><span class="linenos">1144</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="BigQuery.Generator.timetostr_sql-1145"><a href="#BigQuery.Generator.timetostr_sql-1145"><span class="linenos">1145</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATE"</span> -</span><span id="BigQuery.Generator.timetostr_sql-1146"><a href="#BigQuery.Generator.timetostr_sql-1146"><span class="linenos">1146</span></a> -</span><span id="BigQuery.Generator.timetostr_sql-1147"><a href="#BigQuery.Generator.timetostr_sql-1147"><span class="linenos">1147</span></a> <span class="n">time_expr</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="BigQuery.Generator.timetostr_sql-1148"><a href="#BigQuery.Generator.timetostr_sql-1148"><span class="linenos">1148</span></a> <span class="n">this</span> -</span><span id="BigQuery.Generator.timetostr_sql-1149"><a href="#BigQuery.Generator.timetostr_sql-1149"><span class="linenos">1149</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="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">))</span> -</span><span id="BigQuery.Generator.timetostr_sql-1150"><a href="#BigQuery.Generator.timetostr_sql-1150"><span class="linenos">1150</span></a> <span class="k">else</span> <span class="n">expression</span> -</span><span id="BigQuery.Generator.timetostr_sql-1151"><a href="#BigQuery.Generator.timetostr_sql-1151"><span class="linenos">1151</span></a> <span class="p">)</span> -</span><span id="BigQuery.Generator.timetostr_sql-1152"><a href="#BigQuery.Generator.timetostr_sql-1152"><span class="linenos">1152</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">time_expr</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.timetostr_sql-1142"><a href="#BigQuery.Generator.timetostr_sql-1142"><span class="linenos">1142</span></a> <span class="k">def</span> <span class="nf">timetostr_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.timetostr_sql-1143"><a href="#BigQuery.Generator.timetostr_sql-1143"><span class="linenos">1143</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator.timetostr_sql-1144"><a href="#BigQuery.Generator.timetostr_sql-1144"><span class="linenos">1144</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">TsOrDsToDatetime</span><span class="p">):</span> +</span><span id="BigQuery.Generator.timetostr_sql-1145"><a href="#BigQuery.Generator.timetostr_sql-1145"><span class="linenos">1145</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATETIME"</span> +</span><span id="BigQuery.Generator.timetostr_sql-1146"><a href="#BigQuery.Generator.timetostr_sql-1146"><span class="linenos">1146</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">TsOrDsToTimestamp</span><span class="p">):</span> +</span><span id="BigQuery.Generator.timetostr_sql-1147"><a href="#BigQuery.Generator.timetostr_sql-1147"><span class="linenos">1147</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_TIMESTAMP"</span> +</span><span id="BigQuery.Generator.timetostr_sql-1148"><a href="#BigQuery.Generator.timetostr_sql-1148"><span class="linenos">1148</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="BigQuery.Generator.timetostr_sql-1149"><a href="#BigQuery.Generator.timetostr_sql-1149"><span class="linenos">1149</span></a> <span class="n">func_name</span> <span class="o">=</span> <span class="s2">"FORMAT_DATE"</span> +</span><span id="BigQuery.Generator.timetostr_sql-1150"><a href="#BigQuery.Generator.timetostr_sql-1150"><span class="linenos">1150</span></a> +</span><span id="BigQuery.Generator.timetostr_sql-1151"><a href="#BigQuery.Generator.timetostr_sql-1151"><span class="linenos">1151</span></a> <span class="n">time_expr</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="BigQuery.Generator.timetostr_sql-1152"><a href="#BigQuery.Generator.timetostr_sql-1152"><span class="linenos">1152</span></a> <span class="n">this</span> +</span><span id="BigQuery.Generator.timetostr_sql-1153"><a href="#BigQuery.Generator.timetostr_sql-1153"><span class="linenos">1153</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="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDatetime</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToTimestamp</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">))</span> +</span><span id="BigQuery.Generator.timetostr_sql-1154"><a href="#BigQuery.Generator.timetostr_sql-1154"><span class="linenos">1154</span></a> <span class="k">else</span> <span class="n">expression</span> +</span><span id="BigQuery.Generator.timetostr_sql-1155"><a href="#BigQuery.Generator.timetostr_sql-1155"><span class="linenos">1155</span></a> <span class="p">)</span> +</span><span id="BigQuery.Generator.timetostr_sql-1156"><a href="#BigQuery.Generator.timetostr_sql-1156"><span class="linenos">1156</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">time_expr</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> </span></pre></div> @@ -5113,13 +5140,13 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.eq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.eq_sql-1154"><a href="#BigQuery.Generator.eq_sql-1154"><span class="linenos">1154</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.eq_sql-1155"><a href="#BigQuery.Generator.eq_sql-1155"><span class="linenos">1155</span></a> <span class="c1"># Operands of = cannot be NULL in BigQuery</span> -</span><span id="BigQuery.Generator.eq_sql-1156"><a href="#BigQuery.Generator.eq_sql-1156"><span class="linenos">1156</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">right</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">):</span> -</span><span id="BigQuery.Generator.eq_sql-1157"><a href="#BigQuery.Generator.eq_sql-1157"><span class="linenos">1157</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="BigQuery.Generator.eq_sql-1158"><a href="#BigQuery.Generator.eq_sql-1158"><span class="linenos">1158</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> -</span><span id="BigQuery.Generator.eq_sql-1159"><a href="#BigQuery.Generator.eq_sql-1159"><span class="linenos">1159</span></a> -</span><span id="BigQuery.Generator.eq_sql-1160"><a href="#BigQuery.Generator.eq_sql-1160"><span class="linenos">1160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.eq_sql-1158"><a href="#BigQuery.Generator.eq_sql-1158"><span class="linenos">1158</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.eq_sql-1159"><a href="#BigQuery.Generator.eq_sql-1159"><span class="linenos">1159</span></a> <span class="c1"># Operands of = cannot be NULL in BigQuery</span> +</span><span id="BigQuery.Generator.eq_sql-1160"><a href="#BigQuery.Generator.eq_sql-1160"><span class="linenos">1160</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">right</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">):</span> +</span><span id="BigQuery.Generator.eq_sql-1161"><a href="#BigQuery.Generator.eq_sql-1161"><span class="linenos">1161</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="BigQuery.Generator.eq_sql-1162"><a href="#BigQuery.Generator.eq_sql-1162"><span class="linenos">1162</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> +</span><span id="BigQuery.Generator.eq_sql-1163"><a href="#BigQuery.Generator.eq_sql-1163"><span class="linenos">1163</span></a> +</span><span id="BigQuery.Generator.eq_sql-1164"><a href="#BigQuery.Generator.eq_sql-1164"><span class="linenos">1164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> </span></pre></div> @@ -5137,17 +5164,17 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.attimezone_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.attimezone_sql-1162"><a href="#BigQuery.Generator.attimezone_sql-1162"><span class="linenos">1162</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.attimezone_sql-1163"><a href="#BigQuery.Generator.attimezone_sql-1163"><span class="linenos">1163</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> -</span><span id="BigQuery.Generator.attimezone_sql-1164"><a href="#BigQuery.Generator.attimezone_sql-1164"><span class="linenos">1164</span></a> -</span><span id="BigQuery.Generator.attimezone_sql-1165"><a href="#BigQuery.Generator.attimezone_sql-1165"><span class="linenos">1165</span></a> <span class="c1"># BigQuery allows CAST(.. AS {STRING|TIMESTAMP} [FORMAT <fmt> [AT TIME ZONE <tz>]]).</span> -</span><span id="BigQuery.Generator.attimezone_sql-1166"><a href="#BigQuery.Generator.attimezone_sql-1166"><span class="linenos">1166</span></a> <span class="c1"># Only the TIMESTAMP one should use the below conversion, when AT TIME ZONE is included.</span> -</span><span id="BigQuery.Generator.attimezone_sql-1167"><a href="#BigQuery.Generator.attimezone_sql-1167"><span class="linenos">1167</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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> -</span><span id="BigQuery.Generator.attimezone_sql-1168"><a href="#BigQuery.Generator.attimezone_sql-1168"><span class="linenos">1168</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="BigQuery.Generator.attimezone_sql-1169"><a href="#BigQuery.Generator.attimezone_sql-1169"><span class="linenos">1169</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">))</span> -</span><span id="BigQuery.Generator.attimezone_sql-1170"><a href="#BigQuery.Generator.attimezone_sql-1170"><span class="linenos">1170</span></a> <span class="p">)</span> -</span><span id="BigQuery.Generator.attimezone_sql-1171"><a href="#BigQuery.Generator.attimezone_sql-1171"><span class="linenos">1171</span></a> -</span><span id="BigQuery.Generator.attimezone_sql-1172"><a href="#BigQuery.Generator.attimezone_sql-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">attimezone_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.attimezone_sql-1166"><a href="#BigQuery.Generator.attimezone_sql-1166"><span class="linenos">1166</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.attimezone_sql-1167"><a href="#BigQuery.Generator.attimezone_sql-1167"><span class="linenos">1167</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> +</span><span id="BigQuery.Generator.attimezone_sql-1168"><a href="#BigQuery.Generator.attimezone_sql-1168"><span class="linenos">1168</span></a> +</span><span id="BigQuery.Generator.attimezone_sql-1169"><a href="#BigQuery.Generator.attimezone_sql-1169"><span class="linenos">1169</span></a> <span class="c1"># BigQuery allows CAST(.. AS {STRING|TIMESTAMP} [FORMAT <fmt> [AT TIME ZONE <tz>]]).</span> +</span><span id="BigQuery.Generator.attimezone_sql-1170"><a href="#BigQuery.Generator.attimezone_sql-1170"><span class="linenos">1170</span></a> <span class="c1"># Only the TIMESTAMP one should use the below conversion, when AT TIME ZONE is included.</span> +</span><span id="BigQuery.Generator.attimezone_sql-1171"><a href="#BigQuery.Generator.attimezone_sql-1171"><span class="linenos">1171</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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">parent</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> +</span><span id="BigQuery.Generator.attimezone_sql-1172"><a href="#BigQuery.Generator.attimezone_sql-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="BigQuery.Generator.attimezone_sql-1173"><a href="#BigQuery.Generator.attimezone_sql-1173"><span class="linenos">1173</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"zone"</span><span class="p">))</span> +</span><span id="BigQuery.Generator.attimezone_sql-1174"><a href="#BigQuery.Generator.attimezone_sql-1174"><span class="linenos">1174</span></a> <span class="p">)</span> +</span><span id="BigQuery.Generator.attimezone_sql-1175"><a href="#BigQuery.Generator.attimezone_sql-1175"><span class="linenos">1175</span></a> +</span><span id="BigQuery.Generator.attimezone_sql-1176"><a href="#BigQuery.Generator.attimezone_sql-1176"><span class="linenos">1176</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">attimezone_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -5165,8 +5192,8 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.trycast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.trycast_sql-1174"><a href="#BigQuery.Generator.trycast_sql-1174"><span class="linenos">1174</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.trycast_sql-1175"><a href="#BigQuery.Generator.trycast_sql-1175"><span class="linenos">1175</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"SAFE_"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.trycast_sql-1178"><a href="#BigQuery.Generator.trycast_sql-1178"><span class="linenos">1178</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.trycast_sql-1179"><a href="#BigQuery.Generator.trycast_sql-1179"><span class="linenos">1179</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"SAFE_"</span><span class="p">)</span> </span></pre></div> @@ -5184,35 +5211,35 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.bracket_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.bracket_sql-1177"><a href="#BigQuery.Generator.bracket_sql-1177"><span class="linenos">1177</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.bracket_sql-1178"><a href="#BigQuery.Generator.bracket_sql-1178"><span class="linenos">1178</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery.Generator.bracket_sql-1179"><a href="#BigQuery.Generator.bracket_sql-1179"><span class="linenos">1179</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="BigQuery.Generator.bracket_sql-1180"><a href="#BigQuery.Generator.bracket_sql-1180"><span class="linenos">1180</span></a> -</span><span id="BigQuery.Generator.bracket_sql-1181"><a href="#BigQuery.Generator.bracket_sql-1181"><span class="linenos">1181</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="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">):</span> -</span><span id="BigQuery.Generator.bracket_sql-1182"><a href="#BigQuery.Generator.bracket_sql-1182"><span class="linenos">1182</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="BigQuery.Generator.bracket_sql-1183"><a href="#BigQuery.Generator.bracket_sql-1183"><span class="linenos">1183</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="BigQuery.Generator.bracket_sql-1184"><a href="#BigQuery.Generator.bracket_sql-1184"><span class="linenos">1184</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> -</span><span id="BigQuery.Generator.bracket_sql-1185"><a href="#BigQuery.Generator.bracket_sql-1185"><span class="linenos">1185</span></a> -</span><span id="BigQuery.Generator.bracket_sql-1186"><a href="#BigQuery.Generator.bracket_sql-1186"><span class="linenos">1186</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> -</span><span id="BigQuery.Generator.bracket_sql-1187"><a href="#BigQuery.Generator.bracket_sql-1187"><span class="linenos">1187</span></a> -</span><span id="BigQuery.Generator.bracket_sql-1188"><a href="#BigQuery.Generator.bracket_sql-1188"><span class="linenos">1188</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">and</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</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">TEXT_TYPES</span><span class="p">:</span> -</span><span id="BigQuery.Generator.bracket_sql-1189"><a href="#BigQuery.Generator.bracket_sql-1189"><span class="linenos">1189</span></a> <span class="c1"># BQ doesn't support bracket syntax with string values for structs</span> -</span><span id="BigQuery.Generator.bracket_sql-1190"><a href="#BigQuery.Generator.bracket_sql-1190"><span class="linenos">1190</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.bracket_sql-1181"><a href="#BigQuery.Generator.bracket_sql-1181"><span class="linenos">1181</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.bracket_sql-1182"><a href="#BigQuery.Generator.bracket_sql-1182"><span class="linenos">1182</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator.bracket_sql-1183"><a href="#BigQuery.Generator.bracket_sql-1183"><span class="linenos">1183</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="BigQuery.Generator.bracket_sql-1184"><a href="#BigQuery.Generator.bracket_sql-1184"><span class="linenos">1184</span></a> +</span><span id="BigQuery.Generator.bracket_sql-1185"><a href="#BigQuery.Generator.bracket_sql-1185"><span class="linenos">1185</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="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">):</span> +</span><span id="BigQuery.Generator.bracket_sql-1186"><a href="#BigQuery.Generator.bracket_sql-1186"><span class="linenos">1186</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="BigQuery.Generator.bracket_sql-1187"><a href="#BigQuery.Generator.bracket_sql-1187"><span class="linenos">1187</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="BigQuery.Generator.bracket_sql-1188"><a href="#BigQuery.Generator.bracket_sql-1188"><span class="linenos">1188</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="BigQuery.Generator.bracket_sql-1189"><a href="#BigQuery.Generator.bracket_sql-1189"><span class="linenos">1189</span></a> +</span><span id="BigQuery.Generator.bracket_sql-1190"><a href="#BigQuery.Generator.bracket_sql-1190"><span class="linenos">1190</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> </span><span id="BigQuery.Generator.bracket_sql-1191"><a href="#BigQuery.Generator.bracket_sql-1191"><span class="linenos">1191</span></a> -</span><span id="BigQuery.Generator.bracket_sql-1192"><a href="#BigQuery.Generator.bracket_sql-1192"><span class="linenos">1192</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="BigQuery.Generator.bracket_sql-1193"><a href="#BigQuery.Generator.bracket_sql-1193"><span class="linenos">1193</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> -</span><span id="BigQuery.Generator.bracket_sql-1194"><a href="#BigQuery.Generator.bracket_sql-1194"><span class="linenos">1194</span></a> -</span><span id="BigQuery.Generator.bracket_sql-1195"><a href="#BigQuery.Generator.bracket_sql-1195"><span class="linenos">1195</span></a> <span class="k">if</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="BigQuery.Generator.bracket_sql-1196"><a href="#BigQuery.Generator.bracket_sql-1196"><span class="linenos">1196</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OFFSET(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="BigQuery.Generator.bracket_sql-1197"><a href="#BigQuery.Generator.bracket_sql-1197"><span class="linenos">1197</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="BigQuery.Generator.bracket_sql-1198"><a href="#BigQuery.Generator.bracket_sql-1198"><span class="linenos">1198</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ORDINAL(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="BigQuery.Generator.bracket_sql-1199"><a href="#BigQuery.Generator.bracket_sql-1199"><span class="linenos">1199</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="BigQuery.Generator.bracket_sql-1200"><a href="#BigQuery.Generator.bracket_sql-1200"><span class="linenos">1200</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported array offset: </span><span class="si">{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="BigQuery.Generator.bracket_sql-1201"><a href="#BigQuery.Generator.bracket_sql-1201"><span class="linenos">1201</span></a> -</span><span id="BigQuery.Generator.bracket_sql-1202"><a href="#BigQuery.Generator.bracket_sql-1202"><span class="linenos">1202</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">):</span> -</span><span id="BigQuery.Generator.bracket_sql-1203"><a href="#BigQuery.Generator.bracket_sql-1203"><span class="linenos">1203</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"SAFE_</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator.bracket_sql-1204"><a href="#BigQuery.Generator.bracket_sql-1204"><span class="linenos">1204</span></a> -</span><span id="BigQuery.Generator.bracket_sql-1205"><a href="#BigQuery.Generator.bracket_sql-1205"><span class="linenos">1205</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="BigQuery.Generator.bracket_sql-1192"><a href="#BigQuery.Generator.bracket_sql-1192"><span class="linenos">1192</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span> <span class="ow">and</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</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">TEXT_TYPES</span><span class="p">:</span> +</span><span id="BigQuery.Generator.bracket_sql-1193"><a href="#BigQuery.Generator.bracket_sql-1193"><span class="linenos">1193</span></a> <span class="c1"># BQ doesn't support bracket syntax with string values for structs</span> +</span><span id="BigQuery.Generator.bracket_sql-1194"><a href="#BigQuery.Generator.bracket_sql-1194"><span class="linenos">1194</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator.bracket_sql-1195"><a href="#BigQuery.Generator.bracket_sql-1195"><span class="linenos">1195</span></a> +</span><span id="BigQuery.Generator.bracket_sql-1196"><a href="#BigQuery.Generator.bracket_sql-1196"><span class="linenos">1196</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="BigQuery.Generator.bracket_sql-1197"><a href="#BigQuery.Generator.bracket_sql-1197"><span class="linenos">1197</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> +</span><span id="BigQuery.Generator.bracket_sql-1198"><a href="#BigQuery.Generator.bracket_sql-1198"><span class="linenos">1198</span></a> +</span><span id="BigQuery.Generator.bracket_sql-1199"><a href="#BigQuery.Generator.bracket_sql-1199"><span class="linenos">1199</span></a> <span class="k">if</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="BigQuery.Generator.bracket_sql-1200"><a href="#BigQuery.Generator.bracket_sql-1200"><span class="linenos">1200</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OFFSET(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="BigQuery.Generator.bracket_sql-1201"><a href="#BigQuery.Generator.bracket_sql-1201"><span class="linenos">1201</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="BigQuery.Generator.bracket_sql-1202"><a href="#BigQuery.Generator.bracket_sql-1202"><span class="linenos">1202</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ORDINAL(</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="BigQuery.Generator.bracket_sql-1203"><a href="#BigQuery.Generator.bracket_sql-1203"><span class="linenos">1203</span></a> <span class="k">elif</span> <span class="n">offset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="BigQuery.Generator.bracket_sql-1204"><a href="#BigQuery.Generator.bracket_sql-1204"><span class="linenos">1204</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported array offset: </span><span class="si">{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="BigQuery.Generator.bracket_sql-1205"><a href="#BigQuery.Generator.bracket_sql-1205"><span class="linenos">1205</span></a> +</span><span id="BigQuery.Generator.bracket_sql-1206"><a href="#BigQuery.Generator.bracket_sql-1206"><span class="linenos">1206</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">):</span> +</span><span id="BigQuery.Generator.bracket_sql-1207"><a href="#BigQuery.Generator.bracket_sql-1207"><span class="linenos">1207</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"SAFE_</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator.bracket_sql-1208"><a href="#BigQuery.Generator.bracket_sql-1208"><span class="linenos">1208</span></a> +</span><span id="BigQuery.Generator.bracket_sql-1209"><a href="#BigQuery.Generator.bracket_sql-1209"><span class="linenos">1209</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> </span></pre></div> @@ -5230,8 +5257,8 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.in_unnest_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.in_unnest_op-1207"><a href="#BigQuery.Generator.in_unnest_op-1207"><span class="linenos">1207</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.in_unnest_op-1208"><a href="#BigQuery.Generator.in_unnest_op-1208"><span class="linenos">1208</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.in_unnest_op-1211"><a href="#BigQuery.Generator.in_unnest_op-1211"><span class="linenos">1211</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.in_unnest_op-1212"><a href="#BigQuery.Generator.in_unnest_op-1212"><span class="linenos">1212</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -5249,10 +5276,10 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.version_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.version_sql-1210"><a href="#BigQuery.Generator.version_sql-1210"><span class="linenos">1210</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.version_sql-1211"><a href="#BigQuery.Generator.version_sql-1211"><span class="linenos">1211</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> -</span><span id="BigQuery.Generator.version_sql-1212"><a href="#BigQuery.Generator.version_sql-1212"><span class="linenos">1212</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"SYSTEM_TIME"</span><span class="p">)</span> -</span><span id="BigQuery.Generator.version_sql-1213"><a href="#BigQuery.Generator.version_sql-1213"><span class="linenos">1213</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">version_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.version_sql-1214"><a href="#BigQuery.Generator.version_sql-1214"><span class="linenos">1214</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.version_sql-1215"><a href="#BigQuery.Generator.version_sql-1215"><span class="linenos">1215</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> +</span><span id="BigQuery.Generator.version_sql-1216"><a href="#BigQuery.Generator.version_sql-1216"><span class="linenos">1216</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"SYSTEM_TIME"</span><span class="p">)</span> +</span><span id="BigQuery.Generator.version_sql-1217"><a href="#BigQuery.Generator.version_sql-1217"><span class="linenos">1217</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">version_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -5270,15 +5297,15 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.contains_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.contains_sql-1215"><a href="#BigQuery.Generator.contains_sql-1215"><span class="linenos">1215</span></a> <span class="k">def</span> <span class="nf">contains_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Contains</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.contains_sql-1216"><a href="#BigQuery.Generator.contains_sql-1216"><span class="linenos">1216</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="BigQuery.Generator.contains_sql-1217"><a href="#BigQuery.Generator.contains_sql-1217"><span class="linenos">1217</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="BigQuery.Generator.contains_sql-1218"><a href="#BigQuery.Generator.contains_sql-1218"><span class="linenos">1218</span></a> -</span><span id="BigQuery.Generator.contains_sql-1219"><a href="#BigQuery.Generator.contains_sql-1219"><span class="linenos">1219</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">Lower</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">):</span> -</span><span id="BigQuery.Generator.contains_sql-1220"><a href="#BigQuery.Generator.contains_sql-1220"><span class="linenos">1220</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="BigQuery.Generator.contains_sql-1221"><a href="#BigQuery.Generator.contains_sql-1221"><span class="linenos">1221</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="o">.</span><span class="n">this</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.contains_sql-1219"><a href="#BigQuery.Generator.contains_sql-1219"><span class="linenos">1219</span></a> <span class="k">def</span> <span class="nf">contains_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Contains</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.contains_sql-1220"><a href="#BigQuery.Generator.contains_sql-1220"><span class="linenos">1220</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator.contains_sql-1221"><a href="#BigQuery.Generator.contains_sql-1221"><span class="linenos">1221</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> </span><span id="BigQuery.Generator.contains_sql-1222"><a href="#BigQuery.Generator.contains_sql-1222"><span class="linenos">1222</span></a> -</span><span id="BigQuery.Generator.contains_sql-1223"><a href="#BigQuery.Generator.contains_sql-1223"><span class="linenos">1223</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONTAINS_SUBSTR"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> +</span><span id="BigQuery.Generator.contains_sql-1223"><a href="#BigQuery.Generator.contains_sql-1223"><span class="linenos">1223</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">Lower</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">):</span> +</span><span id="BigQuery.Generator.contains_sql-1224"><a href="#BigQuery.Generator.contains_sql-1224"><span class="linenos">1224</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="BigQuery.Generator.contains_sql-1225"><a href="#BigQuery.Generator.contains_sql-1225"><span class="linenos">1225</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="o">.</span><span class="n">this</span> +</span><span id="BigQuery.Generator.contains_sql-1226"><a href="#BigQuery.Generator.contains_sql-1226"><span class="linenos">1226</span></a> +</span><span id="BigQuery.Generator.contains_sql-1227"><a href="#BigQuery.Generator.contains_sql-1227"><span class="linenos">1227</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONTAINS_SUBSTR"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> </span></pre></div> |