diff options
Diffstat (limited to 'docs/sqlglot/dialects/presto.html')
-rw-r--r-- | docs/sqlglot/dialects/presto.html | 1863 |
1 files changed, 942 insertions, 921 deletions
diff --git a/docs/sqlglot/dialects/presto.html b/docs/sqlglot/dialects/presto.html index bf2d6db..9243539 100644 --- a/docs/sqlglot/dialects/presto.html +++ b/docs/sqlglot/dialects/presto.html @@ -76,6 +76,9 @@ <a class="class" href="#Presto.Parser">Presto.Parser</a> <ul class="memberlist"> <li> + <a class="variable" href="#Presto.Parser.VALUES_FOLLOWED_BY_PAREN">VALUES_FOLLOWED_BY_PAREN</a> + </li> + <li> <a class="variable" href="#Presto.Parser.FUNCTIONS">FUNCTIONS</a> </li> <li> @@ -481,293 +484,295 @@ </span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="p">}</span> </span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> </span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="s2">"ARBITRARY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="s2">"BITWISE_AND"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">),</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="s2">"BITWISE_NOT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="s2">"BITWISE_OR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">),</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="s2">"BITWISE_XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="s2">"CONTAINS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="p">),</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="p">),</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">(</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)],</span> <span class="n">offset</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="kc">True</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="p">),</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="s2">"FROM_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">replace</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="p">),</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">group</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="p">),</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">replacement</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">),</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="p">),</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="s2">"SET_AGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="s2">"SPLIT_TO_MAP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="s2">"STRPOS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">substr</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">instance</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="p">),</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="s2">"TO_CHAR"</span><span class="p">:</span> <span class="n">_parse_to_char</span><span class="p">,</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="s2">"TO_UNIXTIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="s2">"TO_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="p">),</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="p">}</span> -</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> -</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="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-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="n">LIKE_PROPERTY_INSIDE_SCHEMA</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</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-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</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-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="p">}</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> -</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</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-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="p">}</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="o">**</span><span class="n">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-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARBITRARY"</span><span class="p">),</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"ARRAY[</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">]"</span><span class="p">,</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> -</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SET_AGG"</span><span class="p">),</span> -</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"AT_TIMEZONE"</span><span class="p">),</span> -</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_AND(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_OR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_XOR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="n">_to_int</span><span class="p">(</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="p">),</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="p">),</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="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-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="p">),</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span 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-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> -</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="n">_to_int</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span> <span class="o">*</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> -</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="p">),</span> -</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"FROM_UTF8"</span><span class="p">),</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"TO_UTF8"</span><span class="p">),</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"FORMAT='</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">First</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FirstValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromTimeZone</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"WITH_TIMEZONE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'zone'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AT TIME ZONE 'UTC'"</span><span class="p">,</span> -</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unalias_group</span><span class="p">]),</span> -</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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-373"><a href="#L-373"><span class="linenos">373</span></a> <span class="s2">"ARRAY_JOIN"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ARRAY_AGG"</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">"separator"</span><span class="p">)</span> -</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="p">),</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> -</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(),</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos">377</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-378"><a href="#L-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> -</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"JSON_PARSE"</span><span class="p">),</span> -</span><span id="L-380"><a href="#L-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Last</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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">"LAST_DAY_OF_MONTH"</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-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> -</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> -</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> -</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> -</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos">395</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-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="p">[</span> -</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos">398</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-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> -</span><span id="L-400"><a href="#L-400"><span class="linenos">400</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-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="p">]</span> -</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> <span class="p">),</span> -</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> -</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> -</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">_str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> -</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SPLIT_TO_MAP"</span><span class="p">),</span> -</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> -</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> -</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_unnest_sequence</span><span class="p">]),</span> -</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> -</span><span id="L-413"><a href="#L-413"><span class="linenos">413</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">,</span> -</span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="L-415"><a href="#L-415"><span class="linenos">415</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-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_UNIXTIME"</span><span class="p">),</span> -</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> -</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">_ts_or_ds_diff_sql</span><span class="p">,</span> -</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> -</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-430"><a href="#L-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-432"><a href="#L-432"><span class="linenos">432</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-433"><a href="#L-433"><span class="linenos">433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS VARCHAR)"</span><span class="p">,</span> -</span><span id="L-435"><a href="#L-435"><span class="linenos">435</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-436"><a href="#L-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">add_recursive_cte_column_names</span><span class="p">]),</span> -</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> -</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> <span class="p">),</span> -</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</span><span class="p">,</span> -</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a> <span class="p">}</span> -</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a> -</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a> <span class="k">def</span> <span class="nf">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-444"><a href="#L-444"><span class="linenos">444</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-445"><a href="#L-445"><span class="linenos">445</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-446"><a href="#L-446"><span class="linenos">446</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">,</span> -</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a> <span class="n">seq_get</span><span class="p">(</span> -</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> <span class="n">apply_index_offset</span><span class="p">(</span> -</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a> <span class="mi">1</span> <span class="o">-</span> <span class="n">expression</span><span 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 class="mi">0</span><span class="p">),</span> -</span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a> <span class="p">),</span> -</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a> <span class="mi">0</span><span class="p">,</span> -</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a> <span class="p">),</span> -</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a> <span class="p">)</span> -</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a> -</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a> <span class="k">def</span> <span class="nf">struct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-460"><a href="#L-460"><span class="linenos">460</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEY_VALUE_DEFINITIONS</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="L-461"><a href="#L-461"><span class="linenos">461</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Struct with key-value definitions is unsupported."</span><span class="p">)</span> -</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a> -</span><span id="L-464"><a href="#L-464"><span class="linenos">464</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ROW"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="s2">"ARBITRARY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="s2">"BITWISE_AND"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">),</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="s2">"BITWISE_NOT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="s2">"BITWISE_OR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">),</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="s2">"BITWISE_XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="s2">"CONTAINS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="p">),</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="p">),</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">(</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)],</span> <span class="n">offset</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="kc">True</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="p">),</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"FROM_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">replace</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="p">),</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">group</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="p">),</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="n">replacement</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">),</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="p">),</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="s2">"SET_AGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="s2">"SPLIT_TO_MAP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="s2">"STRPOS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> +</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">substr</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">instance</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="p">),</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="s2">"TO_CHAR"</span><span class="p">:</span> <span class="n">_parse_to_char</span><span class="p">,</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="s2">"TO_UNIXTIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="s2">"TO_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="p">),</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="p">}</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> +</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="k">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-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="n">LIKE_PROPERTY_INSIDE_SCHEMA</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> +</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos">300</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-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</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-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="p">}</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="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-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="p">}</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARBITRARY"</span><span class="p">),</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"ARRAY[</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">]"</span><span class="p">,</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SET_AGG"</span><span class="p">),</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"AT_TIMEZONE"</span><span class="p">),</span> +</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_AND(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_OR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_XOR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> +</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="n">_to_int</span><span class="p">(</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="p">),</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="p">),</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="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-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="p">),</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="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-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="n">_to_int</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span> <span class="o">*</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="p">),</span> +</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"FROM_UTF8"</span><span class="p">),</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"TO_UTF8"</span><span class="p">),</span> +</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"FORMAT='</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> +</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">First</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FirstValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromTimeZone</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"WITH_TIMEZONE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'zone'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AT TIME ZONE 'UTC'"</span><span class="p">,</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unalias_group</span><span class="p">]),</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="s2">"ARRAY_JOIN"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ARRAY_AGG"</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">"separator"</span><span class="p">)</span> +</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="p">),</span> +</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(),</span> +</span><span id="L-379"><a href="#L-379"><span class="linenos">379</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-380"><a href="#L-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> +</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"JSON_PARSE"</span><span class="p">),</span> +</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Last</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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">"LAST_DAY_OF_MONTH"</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-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> +</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> +</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> +</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> +</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> +</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> +</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> +</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-397"><a href="#L-397"><span class="linenos">397</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-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="p">[</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos">400</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-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> +</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">,</span> +</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="p">]</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> <span class="p">),</span> +</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> +</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">_str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SPLIT_TO_MAP"</span><span class="p">),</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> +</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> +</span><span id="L-413"><a href="#L-413"><span class="linenos">413</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_unnest_sequence</span><span class="p">]),</span> +</span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> +</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">,</span> +</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="L-417"><a href="#L-417"><span class="linenos">417</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-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_UNIXTIME"</span><span class="p">),</span> +</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">_ts_or_ds_diff_sql</span><span class="p">,</span> +</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> +</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-432"><a href="#L-432"><span class="linenos">432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-434"><a href="#L-434"><span class="linenos">434</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-435"><a href="#L-435"><span class="linenos">435</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS VARCHAR)"</span><span class="p">,</span> +</span><span id="L-437"><a href="#L-437"><span class="linenos">437</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-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">add_recursive_cte_column_names</span><span class="p">]),</span> +</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> +</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a> <span class="p">),</span> +</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</span><span class="p">,</span> +</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a> <span class="p">}</span> +</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a> +</span><span id="L-445"><a href="#L-445"><span class="linenos">445</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-446"><a href="#L-446"><span class="linenos">446</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-447"><a href="#L-447"><span class="linenos">447</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-448"><a href="#L-448"><span class="linenos">448</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">,</span> +</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> <span class="n">seq_get</span><span class="p">(</span> +</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a> <span class="n">apply_index_offset</span><span class="p">(</span> +</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a> <span class="mi">1</span> <span class="o">-</span> <span class="n">expression</span><span 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 class="mi">0</span><span class="p">),</span> +</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a> <span class="p">),</span> +</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a> <span class="mi">0</span><span class="p">,</span> +</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a> <span class="p">),</span> +</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a> <span class="p">)</span> +</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-460"><a href="#L-460"><span class="linenos">460</span></a> +</span><span id="L-461"><a href="#L-461"><span class="linenos">461</span></a> <span class="k">def</span> <span class="nf">struct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEY_VALUE_DEFINITIONS</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Struct with key-value definitions is unsupported."</span><span class="p">)</span> +</span><span id="L-464"><a href="#L-464"><span class="linenos">464</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-465"><a href="#L-465"><span class="linenos">465</span></a> -</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> -</span><span id="L-469"><a href="#L-469"><span class="linenos">469</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' DAY)"</span> -</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> -</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> -</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> -</span><span id="L-477"><a href="#L-477"><span class="linenos">477</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-478"><a href="#L-478"><span class="linenos">478</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> -</span><span id="L-479"><a href="#L-479"><span class="linenos">479</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"end"</span><span class="p">]</span> -</span><span id="L-480"><a href="#L-480"><span class="linenos">480</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> -</span><span id="L-481"><a href="#L-481"><span class="linenos">481</span></a> -</span><span id="L-482"><a href="#L-482"><span class="linenos">482</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="L-483"><a href="#L-483"><span class="linenos">483</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> -</span><span id="L-484"><a href="#L-484"><span class="linenos">484</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="L-485"><a href="#L-485"><span class="linenos">485</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> -</span><span id="L-486"><a href="#L-486"><span class="linenos">486</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-487"><a href="#L-487"><span class="linenos">487</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-488"><a href="#L-488"><span class="linenos">488</span></a> -</span><span id="L-489"><a href="#L-489"><span class="linenos">489</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> -</span><span id="L-490"><a href="#L-490"><span class="linenos">490</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> -</span><span id="L-491"><a href="#L-491"><span class="linenos">491</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> -</span><span id="L-492"><a href="#L-492"><span class="linenos">492</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-493"><a href="#L-493"><span class="linenos">493</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> -</span><span id="L-494"><a href="#L-494"><span class="linenos">494</span></a> -</span><span id="L-495"><a href="#L-495"><span class="linenos">495</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> +</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ROW"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a> +</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-469"><a href="#L-469"><span class="linenos">469</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> +</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' DAY)"</span> +</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a> +</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> +</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-477"><a href="#L-477"><span class="linenos">477</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-478"><a href="#L-478"><span class="linenos">478</span></a> +</span><span id="L-479"><a href="#L-479"><span class="linenos">479</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-480"><a href="#L-480"><span class="linenos">480</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> +</span><span id="L-481"><a href="#L-481"><span class="linenos">481</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"end"</span><span class="p">]</span> +</span><span id="L-482"><a href="#L-482"><span class="linenos">482</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> +</span><span id="L-483"><a href="#L-483"><span class="linenos">483</span></a> +</span><span id="L-484"><a href="#L-484"><span class="linenos">484</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="L-485"><a href="#L-485"><span class="linenos">485</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> +</span><span id="L-486"><a href="#L-486"><span class="linenos">486</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="L-487"><a href="#L-487"><span class="linenos">487</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> +</span><span id="L-488"><a href="#L-488"><span class="linenos">488</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-489"><a href="#L-489"><span class="linenos">489</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-490"><a href="#L-490"><span class="linenos">490</span></a> +</span><span id="L-491"><a href="#L-491"><span class="linenos">491</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> +</span><span id="L-492"><a href="#L-492"><span class="linenos">492</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> +</span><span id="L-493"><a href="#L-493"><span class="linenos">493</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> +</span><span id="L-494"><a href="#L-494"><span class="linenos">494</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-495"><a href="#L-495"><span class="linenos">495</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> </span><span id="L-496"><a href="#L-496"><span class="linenos">496</span></a> -</span><span id="L-497"><a href="#L-497"><span class="linenos">497</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="L-498"><a href="#L-498"><span class="linenos">498</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="L-499"><a href="#L-499"><span class="linenos">499</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-500"><a href="#L-500"><span class="linenos">500</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="L-501"><a href="#L-501"><span class="linenos">501</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="L-502"><a href="#L-502"><span class="linenos">502</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="L-503"><a href="#L-503"><span class="linenos">503</span></a> <span class="p">]</span> -</span><span id="L-504"><a href="#L-504"><span class="linenos">504</span></a> -</span><span id="L-505"><a href="#L-505"><span class="linenos">505</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-506"><a href="#L-506"><span class="linenos">506</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-507"><a href="#L-507"><span class="linenos">507</span></a><span class="sd"> Presto doesn't support CREATE VIEW with expressions (ex: `CREATE VIEW x (cola)` then `(cola)` is the expression),</span> -</span><span id="L-508"><a href="#L-508"><span class="linenos">508</span></a><span class="sd"> so we need to remove them</span> -</span><span id="L-509"><a href="#L-509"><span class="linenos">509</span></a><span class="sd"> """</span> -</span><span id="L-510"><a href="#L-510"><span class="linenos">510</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="L-511"><a href="#L-511"><span class="linenos">511</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"VIEW"</span> <span class="ow">and</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-513"><a href="#L-513"><span class="linenos">513</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-514"><a href="#L-514"><span class="linenos">514</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-497"><a href="#L-497"><span class="linenos">497</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> +</span><span id="L-498"><a href="#L-498"><span class="linenos">498</span></a> +</span><span id="L-499"><a href="#L-499"><span class="linenos">499</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="L-500"><a href="#L-500"><span class="linenos">500</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="L-501"><a href="#L-501"><span class="linenos">501</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-502"><a href="#L-502"><span class="linenos">502</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="L-503"><a href="#L-503"><span class="linenos">503</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="L-504"><a href="#L-504"><span class="linenos">504</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="L-505"><a href="#L-505"><span class="linenos">505</span></a> <span class="p">]</span> +</span><span id="L-506"><a href="#L-506"><span class="linenos">506</span></a> +</span><span id="L-507"><a href="#L-507"><span class="linenos">507</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-508"><a href="#L-508"><span class="linenos">508</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-509"><a href="#L-509"><span class="linenos">509</span></a><span class="sd"> Presto doesn't support CREATE VIEW with expressions (ex: `CREATE VIEW x (cola)` then `(cola)` is the expression),</span> +</span><span id="L-510"><a href="#L-510"><span class="linenos">510</span></a><span class="sd"> so we need to remove them</span> +</span><span id="L-511"><a href="#L-511"><span class="linenos">511</span></a><span class="sd"> """</span> +</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="L-513"><a href="#L-513"><span class="linenos">513</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-514"><a href="#L-514"><span class="linenos">514</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"VIEW"</span> <span class="ow">and</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-515"><a href="#L-515"><span class="linenos">515</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-516"><a href="#L-516"><span class="linenos">516</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -815,293 +820,295 @@ </span><span id="Presto-226"><a href="#Presto-226"><span class="linenos">226</span></a> <span class="p">}</span> </span><span id="Presto-227"><a href="#Presto-227"><span class="linenos">227</span></a> </span><span id="Presto-228"><a href="#Presto-228"><span class="linenos">228</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> -</span><span id="Presto-229"><a href="#Presto-229"><span class="linenos">229</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto-230"><a href="#Presto-230"><span class="linenos">230</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> -</span><span id="Presto-231"><a href="#Presto-231"><span class="linenos">231</span></a> <span class="s2">"ARBITRARY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-232"><a href="#Presto-232"><span class="linenos">232</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-233"><a href="#Presto-233"><span class="linenos">233</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> -</span><span id="Presto-234"><a href="#Presto-234"><span class="linenos">234</span></a> <span class="s2">"BITWISE_AND"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">),</span> -</span><span id="Presto-235"><a href="#Presto-235"><span class="linenos">235</span></a> <span class="s2">"BITWISE_NOT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> -</span><span id="Presto-236"><a href="#Presto-236"><span class="linenos">236</span></a> <span class="s2">"BITWISE_OR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">),</span> -</span><span id="Presto-237"><a href="#Presto-237"><span class="linenos">237</span></a> <span class="s2">"BITWISE_XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> -</span><span id="Presto-238"><a href="#Presto-238"><span class="linenos">238</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-239"><a href="#Presto-239"><span class="linenos">239</span></a> <span class="s2">"CONTAINS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-240"><a href="#Presto-240"><span class="linenos">240</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span> -</span><span id="Presto-241"><a href="#Presto-241"><span class="linenos">241</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="Presto-242"><a href="#Presto-242"><span class="linenos">242</span></a> <span class="p">),</span> -</span><span id="Presto-243"><a href="#Presto-243"><span class="linenos">243</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span> -</span><span id="Presto-244"><a href="#Presto-244"><span class="linenos">244</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="Presto-245"><a href="#Presto-245"><span class="linenos">245</span></a> <span class="p">),</span> -</span><span id="Presto-246"><a href="#Presto-246"><span class="linenos">246</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> -</span><span id="Presto-247"><a href="#Presto-247"><span class="linenos">247</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> -</span><span id="Presto-248"><a href="#Presto-248"><span class="linenos">248</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> -</span><span id="Presto-249"><a href="#Presto-249"><span class="linenos">249</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">(</span> -</span><span id="Presto-250"><a href="#Presto-250"><span class="linenos">250</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)],</span> <span class="n">offset</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="kc">True</span> -</span><span id="Presto-251"><a href="#Presto-251"><span class="linenos">251</span></a> <span class="p">),</span> -</span><span id="Presto-252"><a href="#Presto-252"><span class="linenos">252</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-253"><a href="#Presto-253"><span class="linenos">253</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> -</span><span id="Presto-254"><a href="#Presto-254"><span class="linenos">254</span></a> <span class="s2">"FROM_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> -</span><span id="Presto-255"><a href="#Presto-255"><span class="linenos">255</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">replace</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="Presto-256"><a href="#Presto-256"><span class="linenos">256</span></a> <span class="p">),</span> -</span><span id="Presto-257"><a href="#Presto-257"><span class="linenos">257</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-258"><a href="#Presto-258"><span class="linenos">258</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> -</span><span id="Presto-259"><a href="#Presto-259"><span class="linenos">259</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">group</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> -</span><span id="Presto-260"><a href="#Presto-260"><span class="linenos">260</span></a> <span class="p">),</span> -</span><span id="Presto-261"><a href="#Presto-261"><span class="linenos">261</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> -</span><span id="Presto-262"><a href="#Presto-262"><span class="linenos">262</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> -</span><span id="Presto-263"><a href="#Presto-263"><span class="linenos">263</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> -</span><span id="Presto-264"><a href="#Presto-264"><span class="linenos">264</span></a> <span class="n">replacement</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">),</span> -</span><span id="Presto-265"><a href="#Presto-265"><span class="linenos">265</span></a> <span class="p">),</span> -</span><span id="Presto-266"><a href="#Presto-266"><span class="linenos">266</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-267"><a href="#Presto-267"><span class="linenos">267</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-268"><a href="#Presto-268"><span class="linenos">268</span></a> <span class="s2">"SET_AGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-269"><a href="#Presto-269"><span class="linenos">269</span></a> <span class="s2">"SPLIT_TO_MAP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-270"><a href="#Presto-270"><span class="linenos">270</span></a> <span class="s2">"STRPOS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> -</span><span id="Presto-271"><a href="#Presto-271"><span class="linenos">271</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">substr</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">instance</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> -</span><span id="Presto-272"><a href="#Presto-272"><span class="linenos">272</span></a> <span class="p">),</span> -</span><span id="Presto-273"><a href="#Presto-273"><span class="linenos">273</span></a> <span class="s2">"TO_CHAR"</span><span class="p">:</span> <span class="n">_parse_to_char</span><span class="p">,</span> -</span><span id="Presto-274"><a href="#Presto-274"><span class="linenos">274</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-275"><a href="#Presto-275"><span class="linenos">275</span></a> <span class="s2">"TO_UNIXTIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-276"><a href="#Presto-276"><span class="linenos">276</span></a> <span class="s2">"TO_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> -</span><span id="Presto-277"><a href="#Presto-277"><span class="linenos">277</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="Presto-278"><a href="#Presto-278"><span class="linenos">278</span></a> <span class="p">),</span> -</span><span id="Presto-279"><a href="#Presto-279"><span class="linenos">279</span></a> <span class="p">}</span> -</span><span id="Presto-280"><a href="#Presto-280"><span class="linenos">280</span></a> -</span><span id="Presto-281"><a href="#Presto-281"><span class="linenos">281</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Presto-282"><a href="#Presto-282"><span class="linenos">282</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> -</span><span id="Presto-283"><a href="#Presto-283"><span class="linenos">283</span></a> -</span><span id="Presto-284"><a href="#Presto-284"><span class="linenos">284</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="Presto-285"><a href="#Presto-285"><span class="linenos">285</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-286"><a href="#Presto-286"><span class="linenos">286</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-287"><a href="#Presto-287"><span class="linenos">287</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-288"><a href="#Presto-288"><span class="linenos">288</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-289"><a href="#Presto-289"><span class="linenos">289</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-290"><a href="#Presto-290"><span class="linenos">290</span></a> <span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Presto-291"><a href="#Presto-291"><span class="linenos">291</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-292"><a href="#Presto-292"><span class="linenos">292</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="Presto-293"><a href="#Presto-293"><span class="linenos">293</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Presto-294"><a href="#Presto-294"><span class="linenos">294</span></a> <span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-295"><a href="#Presto-295"><span class="linenos">295</span></a> <span class="n">LIKE_PROPERTY_INSIDE_SCHEMA</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Presto-296"><a href="#Presto-296"><span class="linenos">296</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-297"><a href="#Presto-297"><span class="linenos">297</span></a> -</span><span id="Presto-298"><a href="#Presto-298"><span class="linenos">298</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto-299"><a href="#Presto-299"><span class="linenos">299</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Presto-300"><a href="#Presto-300"><span class="linenos">300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Presto-301"><a href="#Presto-301"><span class="linenos">301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Presto-302"><a href="#Presto-302"><span class="linenos">302</span></a> <span class="p">}</span> -</span><span id="Presto-303"><a href="#Presto-303"><span class="linenos">303</span></a> -</span><span id="Presto-304"><a href="#Presto-304"><span class="linenos">304</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto-305"><a href="#Presto-305"><span class="linenos">305</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="Presto-306"><a href="#Presto-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="Presto-307"><a href="#Presto-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="Presto-308"><a href="#Presto-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> -</span><span id="Presto-309"><a href="#Presto-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="Presto-310"><a href="#Presto-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> -</span><span id="Presto-311"><a href="#Presto-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto-312"><a href="#Presto-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> -</span><span id="Presto-313"><a href="#Presto-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto-314"><a href="#Presto-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto-315"><a href="#Presto-315"><span class="linenos">315</span></a> <span class="p">}</span> -</span><span id="Presto-316"><a href="#Presto-316"><span class="linenos">316</span></a> -</span><span id="Presto-317"><a href="#Presto-317"><span class="linenos">317</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto-318"><a href="#Presto-318"><span class="linenos">318</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="Presto-319"><a href="#Presto-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARBITRARY"</span><span class="p">),</span> -</span><span id="Presto-320"><a href="#Presto-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> -</span><span id="Presto-321"><a href="#Presto-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> -</span><span id="Presto-322"><a href="#Presto-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> -</span><span id="Presto-323"><a href="#Presto-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> -</span><span id="Presto-324"><a href="#Presto-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"ARRAY[</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">]"</span><span class="p">,</span> -</span><span id="Presto-325"><a href="#Presto-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> -</span><span id="Presto-326"><a href="#Presto-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> -</span><span id="Presto-327"><a href="#Presto-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> -</span><span id="Presto-328"><a href="#Presto-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SET_AGG"</span><span class="p">),</span> -</span><span id="Presto-329"><a href="#Presto-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"AT_TIMEZONE"</span><span class="p">),</span> -</span><span id="Presto-330"><a href="#Presto-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-331"><a href="#Presto-331"><span class="linenos">331</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_AND(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-332"><a href="#Presto-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-333"><a href="#Presto-333"><span class="linenos">333</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-334"><a href="#Presto-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-335"><a href="#Presto-335"><span class="linenos">335</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-336"><a href="#Presto-336"><span class="linenos">336</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_OR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-337"><a href="#Presto-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-338"><a href="#Presto-338"><span class="linenos">338</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-339"><a href="#Presto-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-340"><a href="#Presto-340"><span class="linenos">340</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_XOR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-341"><a href="#Presto-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="Presto-342"><a href="#Presto-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto-343"><a href="#Presto-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Presto-344"><a href="#Presto-344"><span class="linenos">344</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> -</span><span id="Presto-345"><a href="#Presto-345"><span class="linenos">345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> -</span><span id="Presto-346"><a href="#Presto-346"><span class="linenos">346</span></a> <span class="n">_to_int</span><span class="p">(</span> -</span><span id="Presto-347"><a href="#Presto-347"><span class="linenos">347</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Presto-348"><a href="#Presto-348"><span class="linenos">348</span></a> <span class="p">),</span> -</span><span id="Presto-349"><a href="#Presto-349"><span class="linenos">349</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto-350"><a href="#Presto-350"><span class="linenos">350</span></a> <span class="p">),</span> -</span><span id="Presto-351"><a href="#Presto-351"><span class="linenos">351</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Presto-352"><a href="#Presto-352"><span class="linenos">352</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="Presto-353"><a href="#Presto-353"><span class="linenos">353</span></a> <span class="p">),</span> -</span><span id="Presto-354"><a href="#Presto-354"><span class="linenos">354</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="Presto-355"><a href="#Presto-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-356"><a href="#Presto-356"><span class="linenos">356</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> -</span><span id="Presto-357"><a href="#Presto-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Presto-358"><a href="#Presto-358"><span class="linenos">358</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> -</span><span id="Presto-359"><a href="#Presto-359"><span class="linenos">359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> -</span><span id="Presto-360"><a href="#Presto-360"><span class="linenos">360</span></a> <span class="n">_to_int</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span> <span class="o">*</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> -</span><span id="Presto-361"><a href="#Presto-361"><span class="linenos">361</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto-362"><a href="#Presto-362"><span class="linenos">362</span></a> <span class="p">),</span> -</span><span id="Presto-363"><a href="#Presto-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"FROM_UTF8"</span><span class="p">),</span> -</span><span id="Presto-364"><a href="#Presto-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-365"><a href="#Presto-365"><span class="linenos">365</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> -</span><span id="Presto-366"><a href="#Presto-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"TO_UTF8"</span><span class="p">),</span> -</span><span id="Presto-367"><a href="#Presto-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"FORMAT='</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> -</span><span id="Presto-368"><a href="#Presto-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">First</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="Presto-369"><a href="#Presto-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FirstValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="Presto-370"><a href="#Presto-370"><span class="linenos">370</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><span id="Presto-371"><a href="#Presto-371"><span class="linenos">371</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"WITH_TIMEZONE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'zone'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AT TIME ZONE 'UTC'"</span><span class="p">,</span> -</span><span id="Presto-372"><a href="#Presto-372"><span class="linenos">372</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unalias_group</span><span class="p">]),</span> -</span><span id="Presto-373"><a href="#Presto-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Presto-374"><a href="#Presto-374"><span class="linenos">374</span></a> <span class="s2">"ARRAY_JOIN"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ARRAY_AGG"</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">"separator"</span><span class="p">)</span> -</span><span id="Presto-375"><a href="#Presto-375"><span class="linenos">375</span></a> <span class="p">),</span> -</span><span id="Presto-376"><a href="#Presto-376"><span class="linenos">376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> -</span><span id="Presto-377"><a href="#Presto-377"><span class="linenos">377</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(),</span> -</span><span id="Presto-378"><a href="#Presto-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="Presto-379"><a href="#Presto-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> -</span><span id="Presto-380"><a href="#Presto-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"JSON_PARSE"</span><span class="p">),</span> -</span><span id="Presto-381"><a href="#Presto-381"><span class="linenos">381</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Last</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="Presto-382"><a href="#Presto-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="Presto-383"><a href="#Presto-383"><span class="linenos">383</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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">"LAST_DAY_OF_MONTH"</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="Presto-384"><a href="#Presto-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> -</span><span id="Presto-385"><a href="#Presto-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> -</span><span id="Presto-386"><a href="#Presto-386"><span class="linenos">386</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> -</span><span id="Presto-387"><a href="#Presto-387"><span class="linenos">387</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> -</span><span id="Presto-388"><a href="#Presto-388"><span class="linenos">388</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> -</span><span id="Presto-389"><a href="#Presto-389"><span class="linenos">389</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> -</span><span id="Presto-390"><a href="#Presto-390"><span class="linenos">390</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> -</span><span id="Presto-391"><a href="#Presto-391"><span class="linenos">391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> -</span><span id="Presto-392"><a href="#Presto-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> -</span><span id="Presto-393"><a href="#Presto-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> -</span><span id="Presto-394"><a href="#Presto-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> -</span><span id="Presto-395"><a href="#Presto-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Presto-396"><a href="#Presto-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Presto-397"><a href="#Presto-397"><span class="linenos">397</span></a> <span class="p">[</span> -</span><span id="Presto-398"><a href="#Presto-398"><span class="linenos">398</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> -</span><span id="Presto-399"><a href="#Presto-399"><span class="linenos">399</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="Presto-400"><a href="#Presto-400"><span class="linenos">400</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> -</span><span id="Presto-401"><a href="#Presto-401"><span class="linenos">401</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="Presto-402"><a href="#Presto-402"><span class="linenos">402</span></a> <span class="p">]</span> -</span><span id="Presto-403"><a href="#Presto-403"><span class="linenos">403</span></a> <span class="p">),</span> -</span><span id="Presto-404"><a href="#Presto-404"><span class="linenos">404</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> -</span><span id="Presto-405"><a href="#Presto-405"><span class="linenos">405</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> -</span><span id="Presto-406"><a href="#Presto-406"><span class="linenos">406</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">_str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> -</span><span id="Presto-407"><a href="#Presto-407"><span class="linenos">407</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SPLIT_TO_MAP"</span><span class="p">),</span> -</span><span id="Presto-408"><a href="#Presto-408"><span class="linenos">408</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> -</span><span id="Presto-409"><a href="#Presto-409"><span class="linenos">409</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-410"><a href="#Presto-410"><span class="linenos">410</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Presto-411"><a href="#Presto-411"><span class="linenos">411</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> -</span><span id="Presto-412"><a href="#Presto-412"><span class="linenos">412</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_unnest_sequence</span><span class="p">]),</span> -</span><span id="Presto-413"><a href="#Presto-413"><span class="linenos">413</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> -</span><span id="Presto-414"><a href="#Presto-414"><span class="linenos">414</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">,</span> -</span><span id="Presto-415"><a href="#Presto-415"><span class="linenos">415</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="Presto-416"><a href="#Presto-416"><span class="linenos">416</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="Presto-417"><a href="#Presto-417"><span class="linenos">417</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-418"><a href="#Presto-418"><span class="linenos">418</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Presto-419"><a href="#Presto-419"><span class="linenos">419</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-420"><a href="#Presto-420"><span class="linenos">420</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-421"><a href="#Presto-421"><span class="linenos">421</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_UNIXTIME"</span><span class="p">),</span> -</span><span id="Presto-422"><a href="#Presto-422"><span class="linenos">422</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-423"><a href="#Presto-423"><span class="linenos">423</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-424"><a href="#Presto-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="Presto-425"><a href="#Presto-425"><span class="linenos">425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-426"><a href="#Presto-426"><span class="linenos">426</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> -</span><span id="Presto-427"><a href="#Presto-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="Presto-428"><a href="#Presto-428"><span class="linenos">428</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="Presto-429"><a href="#Presto-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> -</span><span id="Presto-430"><a href="#Presto-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> -</span><span id="Presto-431"><a href="#Presto-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-432"><a href="#Presto-432"><span class="linenos">432</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-433"><a href="#Presto-433"><span class="linenos">433</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="Presto-434"><a href="#Presto-434"><span class="linenos">434</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto-435"><a href="#Presto-435"><span class="linenos">435</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS VARCHAR)"</span><span class="p">,</span> -</span><span id="Presto-436"><a href="#Presto-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> -</span><span id="Presto-437"><a href="#Presto-437"><span class="linenos">437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">add_recursive_cte_column_names</span><span class="p">]),</span> -</span><span id="Presto-438"><a href="#Presto-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Presto-439"><a href="#Presto-439"><span class="linenos">439</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> -</span><span id="Presto-440"><a href="#Presto-440"><span class="linenos">440</span></a> <span class="p">),</span> -</span><span id="Presto-441"><a href="#Presto-441"><span class="linenos">441</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</span><span class="p">,</span> -</span><span id="Presto-442"><a href="#Presto-442"><span class="linenos">442</span></a> <span class="p">}</span> -</span><span id="Presto-443"><a href="#Presto-443"><span class="linenos">443</span></a> -</span><span id="Presto-444"><a href="#Presto-444"><span class="linenos">444</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="Presto-445"><a href="#Presto-445"><span class="linenos">445</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="Presto-446"><a href="#Presto-446"><span class="linenos">446</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="Presto-447"><a href="#Presto-447"><span class="linenos">447</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">,</span> -</span><span id="Presto-448"><a href="#Presto-448"><span class="linenos">448</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto-449"><a href="#Presto-449"><span class="linenos">449</span></a> <span class="n">seq_get</span><span class="p">(</span> -</span><span id="Presto-450"><a href="#Presto-450"><span class="linenos">450</span></a> <span class="n">apply_index_offset</span><span class="p">(</span> -</span><span id="Presto-451"><a href="#Presto-451"><span class="linenos">451</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto-452"><a href="#Presto-452"><span class="linenos">452</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Presto-453"><a href="#Presto-453"><span class="linenos">453</span></a> <span class="mi">1</span> <span class="o">-</span> <span class="n">expression</span><span 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 class="mi">0</span><span class="p">),</span> -</span><span id="Presto-454"><a href="#Presto-454"><span class="linenos">454</span></a> <span class="p">),</span> -</span><span id="Presto-455"><a href="#Presto-455"><span class="linenos">455</span></a> <span class="mi">0</span><span class="p">,</span> -</span><span id="Presto-456"><a href="#Presto-456"><span class="linenos">456</span></a> <span class="p">),</span> -</span><span id="Presto-457"><a href="#Presto-457"><span class="linenos">457</span></a> <span class="p">)</span> -</span><span id="Presto-458"><a href="#Presto-458"><span class="linenos">458</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Presto-459"><a href="#Presto-459"><span class="linenos">459</span></a> -</span><span id="Presto-460"><a href="#Presto-460"><span class="linenos">460</span></a> <span class="k">def</span> <span class="nf">struct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto-461"><a href="#Presto-461"><span class="linenos">461</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEY_VALUE_DEFINITIONS</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="Presto-462"><a href="#Presto-462"><span class="linenos">462</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Struct with key-value definitions is unsupported."</span><span class="p">)</span> -</span><span id="Presto-463"><a href="#Presto-463"><span class="linenos">463</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Presto-464"><a href="#Presto-464"><span class="linenos">464</span></a> -</span><span id="Presto-465"><a href="#Presto-465"><span class="linenos">465</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ROW"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Presto-229"><a href="#Presto-229"><span class="linenos">229</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-230"><a href="#Presto-230"><span class="linenos">230</span></a> +</span><span id="Presto-231"><a href="#Presto-231"><span class="linenos">231</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto-232"><a href="#Presto-232"><span class="linenos">232</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> +</span><span id="Presto-233"><a href="#Presto-233"><span class="linenos">233</span></a> <span class="s2">"ARBITRARY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-234"><a href="#Presto-234"><span class="linenos">234</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-235"><a href="#Presto-235"><span class="linenos">235</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> +</span><span id="Presto-236"><a href="#Presto-236"><span class="linenos">236</span></a> <span class="s2">"BITWISE_AND"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">),</span> +</span><span id="Presto-237"><a href="#Presto-237"><span class="linenos">237</span></a> <span class="s2">"BITWISE_NOT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> +</span><span id="Presto-238"><a href="#Presto-238"><span class="linenos">238</span></a> <span class="s2">"BITWISE_OR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">),</span> +</span><span id="Presto-239"><a href="#Presto-239"><span class="linenos">239</span></a> <span class="s2">"BITWISE_XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> +</span><span id="Presto-240"><a href="#Presto-240"><span class="linenos">240</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-241"><a href="#Presto-241"><span class="linenos">241</span></a> <span class="s2">"CONTAINS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-242"><a href="#Presto-242"><span class="linenos">242</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span> +</span><span id="Presto-243"><a href="#Presto-243"><span class="linenos">243</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="Presto-244"><a href="#Presto-244"><span class="linenos">244</span></a> <span class="p">),</span> +</span><span id="Presto-245"><a href="#Presto-245"><span class="linenos">245</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span> +</span><span id="Presto-246"><a href="#Presto-246"><span class="linenos">246</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="Presto-247"><a href="#Presto-247"><span class="linenos">247</span></a> <span class="p">),</span> +</span><span id="Presto-248"><a href="#Presto-248"><span class="linenos">248</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> +</span><span id="Presto-249"><a href="#Presto-249"><span class="linenos">249</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> +</span><span id="Presto-250"><a href="#Presto-250"><span class="linenos">250</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> +</span><span id="Presto-251"><a href="#Presto-251"><span class="linenos">251</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">(</span> +</span><span id="Presto-252"><a href="#Presto-252"><span class="linenos">252</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)],</span> <span class="n">offset</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="kc">True</span> +</span><span id="Presto-253"><a href="#Presto-253"><span class="linenos">253</span></a> <span class="p">),</span> +</span><span id="Presto-254"><a href="#Presto-254"><span class="linenos">254</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-255"><a href="#Presto-255"><span class="linenos">255</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> +</span><span id="Presto-256"><a href="#Presto-256"><span class="linenos">256</span></a> <span class="s2">"FROM_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> +</span><span id="Presto-257"><a href="#Presto-257"><span class="linenos">257</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">replace</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="Presto-258"><a href="#Presto-258"><span class="linenos">258</span></a> <span class="p">),</span> +</span><span id="Presto-259"><a href="#Presto-259"><span class="linenos">259</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-260"><a href="#Presto-260"><span class="linenos">260</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> +</span><span id="Presto-261"><a href="#Presto-261"><span class="linenos">261</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">group</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +</span><span id="Presto-262"><a href="#Presto-262"><span class="linenos">262</span></a> <span class="p">),</span> +</span><span id="Presto-263"><a href="#Presto-263"><span class="linenos">263</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> +</span><span id="Presto-264"><a href="#Presto-264"><span class="linenos">264</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> +</span><span id="Presto-265"><a href="#Presto-265"><span class="linenos">265</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> +</span><span id="Presto-266"><a href="#Presto-266"><span class="linenos">266</span></a> <span class="n">replacement</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">),</span> +</span><span id="Presto-267"><a href="#Presto-267"><span class="linenos">267</span></a> <span class="p">),</span> +</span><span id="Presto-268"><a href="#Presto-268"><span class="linenos">268</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-269"><a href="#Presto-269"><span class="linenos">269</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-270"><a href="#Presto-270"><span class="linenos">270</span></a> <span class="s2">"SET_AGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-271"><a href="#Presto-271"><span class="linenos">271</span></a> <span class="s2">"SPLIT_TO_MAP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-272"><a href="#Presto-272"><span class="linenos">272</span></a> <span class="s2">"STRPOS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> +</span><span id="Presto-273"><a href="#Presto-273"><span class="linenos">273</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">substr</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">instance</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +</span><span id="Presto-274"><a href="#Presto-274"><span class="linenos">274</span></a> <span class="p">),</span> +</span><span id="Presto-275"><a href="#Presto-275"><span class="linenos">275</span></a> <span class="s2">"TO_CHAR"</span><span class="p">:</span> <span class="n">_parse_to_char</span><span class="p">,</span> +</span><span id="Presto-276"><a href="#Presto-276"><span class="linenos">276</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-277"><a href="#Presto-277"><span class="linenos">277</span></a> <span class="s2">"TO_UNIXTIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-278"><a href="#Presto-278"><span class="linenos">278</span></a> <span class="s2">"TO_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> +</span><span id="Presto-279"><a href="#Presto-279"><span class="linenos">279</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="Presto-280"><a href="#Presto-280"><span class="linenos">280</span></a> <span class="p">),</span> +</span><span id="Presto-281"><a href="#Presto-281"><span class="linenos">281</span></a> <span class="p">}</span> +</span><span id="Presto-282"><a href="#Presto-282"><span class="linenos">282</span></a> +</span><span id="Presto-283"><a href="#Presto-283"><span class="linenos">283</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Presto-284"><a href="#Presto-284"><span class="linenos">284</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="Presto-285"><a href="#Presto-285"><span class="linenos">285</span></a> +</span><span id="Presto-286"><a href="#Presto-286"><span class="linenos">286</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="Presto-287"><a href="#Presto-287"><span class="linenos">287</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-288"><a href="#Presto-288"><span class="linenos">288</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-289"><a href="#Presto-289"><span class="linenos">289</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-290"><a href="#Presto-290"><span class="linenos">290</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-291"><a href="#Presto-291"><span class="linenos">291</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-292"><a href="#Presto-292"><span class="linenos">292</span></a> <span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Presto-293"><a href="#Presto-293"><span class="linenos">293</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-294"><a href="#Presto-294"><span class="linenos">294</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="Presto-295"><a href="#Presto-295"><span class="linenos">295</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Presto-296"><a href="#Presto-296"><span class="linenos">296</span></a> <span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-297"><a href="#Presto-297"><span class="linenos">297</span></a> <span class="n">LIKE_PROPERTY_INSIDE_SCHEMA</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Presto-298"><a href="#Presto-298"><span class="linenos">298</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-299"><a href="#Presto-299"><span class="linenos">299</span></a> +</span><span id="Presto-300"><a href="#Presto-300"><span class="linenos">300</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto-301"><a href="#Presto-301"><span class="linenos">301</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Presto-302"><a href="#Presto-302"><span class="linenos">302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Presto-303"><a href="#Presto-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Presto-304"><a href="#Presto-304"><span class="linenos">304</span></a> <span class="p">}</span> +</span><span id="Presto-305"><a href="#Presto-305"><span class="linenos">305</span></a> +</span><span id="Presto-306"><a href="#Presto-306"><span class="linenos">306</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto-307"><a href="#Presto-307"><span class="linenos">307</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="Presto-308"><a href="#Presto-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="Presto-309"><a href="#Presto-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="Presto-310"><a href="#Presto-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> +</span><span id="Presto-311"><a href="#Presto-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="Presto-312"><a href="#Presto-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> +</span><span id="Presto-313"><a href="#Presto-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto-314"><a href="#Presto-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> +</span><span id="Presto-315"><a href="#Presto-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto-316"><a href="#Presto-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto-317"><a href="#Presto-317"><span class="linenos">317</span></a> <span class="p">}</span> +</span><span id="Presto-318"><a href="#Presto-318"><span class="linenos">318</span></a> +</span><span id="Presto-319"><a href="#Presto-319"><span class="linenos">319</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto-320"><a href="#Presto-320"><span class="linenos">320</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="Presto-321"><a href="#Presto-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARBITRARY"</span><span class="p">),</span> +</span><span id="Presto-322"><a href="#Presto-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> +</span><span id="Presto-323"><a href="#Presto-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> +</span><span id="Presto-324"><a href="#Presto-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> +</span><span id="Presto-325"><a href="#Presto-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> +</span><span id="Presto-326"><a href="#Presto-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"ARRAY[</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">]"</span><span class="p">,</span> +</span><span id="Presto-327"><a href="#Presto-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> +</span><span id="Presto-328"><a href="#Presto-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> +</span><span id="Presto-329"><a href="#Presto-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> +</span><span id="Presto-330"><a href="#Presto-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SET_AGG"</span><span class="p">),</span> +</span><span id="Presto-331"><a href="#Presto-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"AT_TIMEZONE"</span><span class="p">),</span> +</span><span id="Presto-332"><a href="#Presto-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-333"><a href="#Presto-333"><span class="linenos">333</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_AND(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-334"><a href="#Presto-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-335"><a href="#Presto-335"><span class="linenos">335</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-336"><a href="#Presto-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-337"><a href="#Presto-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-338"><a href="#Presto-338"><span class="linenos">338</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_OR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-339"><a href="#Presto-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-340"><a href="#Presto-340"><span class="linenos">340</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-341"><a href="#Presto-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-342"><a href="#Presto-342"><span class="linenos">342</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_XOR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-343"><a href="#Presto-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="Presto-344"><a href="#Presto-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto-345"><a href="#Presto-345"><span class="linenos">345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Presto-346"><a href="#Presto-346"><span class="linenos">346</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> +</span><span id="Presto-347"><a href="#Presto-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> +</span><span id="Presto-348"><a href="#Presto-348"><span class="linenos">348</span></a> <span class="n">_to_int</span><span class="p">(</span> +</span><span id="Presto-349"><a href="#Presto-349"><span class="linenos">349</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Presto-350"><a href="#Presto-350"><span class="linenos">350</span></a> <span class="p">),</span> +</span><span id="Presto-351"><a href="#Presto-351"><span class="linenos">351</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto-352"><a href="#Presto-352"><span class="linenos">352</span></a> <span class="p">),</span> +</span><span id="Presto-353"><a href="#Presto-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Presto-354"><a href="#Presto-354"><span class="linenos">354</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> +</span><span id="Presto-355"><a href="#Presto-355"><span class="linenos">355</span></a> <span class="p">),</span> +</span><span id="Presto-356"><a href="#Presto-356"><span class="linenos">356</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="Presto-357"><a href="#Presto-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-358"><a href="#Presto-358"><span class="linenos">358</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> +</span><span id="Presto-359"><a href="#Presto-359"><span class="linenos">359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Presto-360"><a href="#Presto-360"><span class="linenos">360</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> +</span><span id="Presto-361"><a href="#Presto-361"><span class="linenos">361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> +</span><span id="Presto-362"><a href="#Presto-362"><span class="linenos">362</span></a> <span class="n">_to_int</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span> <span class="o">*</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> +</span><span id="Presto-363"><a href="#Presto-363"><span class="linenos">363</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto-364"><a href="#Presto-364"><span class="linenos">364</span></a> <span class="p">),</span> +</span><span id="Presto-365"><a href="#Presto-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"FROM_UTF8"</span><span class="p">),</span> +</span><span id="Presto-366"><a href="#Presto-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-367"><a href="#Presto-367"><span class="linenos">367</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> +</span><span id="Presto-368"><a href="#Presto-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"TO_UTF8"</span><span class="p">),</span> +</span><span id="Presto-369"><a href="#Presto-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"FORMAT='</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> +</span><span id="Presto-370"><a href="#Presto-370"><span class="linenos">370</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">First</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="Presto-371"><a href="#Presto-371"><span class="linenos">371</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FirstValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="Presto-372"><a href="#Presto-372"><span class="linenos">372</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><span id="Presto-373"><a href="#Presto-373"><span class="linenos">373</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"WITH_TIMEZONE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'zone'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AT TIME ZONE 'UTC'"</span><span class="p">,</span> +</span><span id="Presto-374"><a href="#Presto-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unalias_group</span><span class="p">]),</span> +</span><span id="Presto-375"><a href="#Presto-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Presto-376"><a href="#Presto-376"><span class="linenos">376</span></a> <span class="s2">"ARRAY_JOIN"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ARRAY_AGG"</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">"separator"</span><span class="p">)</span> +</span><span id="Presto-377"><a href="#Presto-377"><span class="linenos">377</span></a> <span class="p">),</span> +</span><span id="Presto-378"><a href="#Presto-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> +</span><span id="Presto-379"><a href="#Presto-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(),</span> +</span><span id="Presto-380"><a href="#Presto-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="Presto-381"><a href="#Presto-381"><span class="linenos">381</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> +</span><span id="Presto-382"><a href="#Presto-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"JSON_PARSE"</span><span class="p">),</span> +</span><span id="Presto-383"><a href="#Presto-383"><span class="linenos">383</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Last</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="Presto-384"><a href="#Presto-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="Presto-385"><a href="#Presto-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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">"LAST_DAY_OF_MONTH"</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="Presto-386"><a href="#Presto-386"><span class="linenos">386</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> +</span><span id="Presto-387"><a href="#Presto-387"><span class="linenos">387</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> +</span><span id="Presto-388"><a href="#Presto-388"><span class="linenos">388</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> +</span><span id="Presto-389"><a href="#Presto-389"><span class="linenos">389</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> +</span><span id="Presto-390"><a href="#Presto-390"><span class="linenos">390</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> +</span><span id="Presto-391"><a href="#Presto-391"><span class="linenos">391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> +</span><span id="Presto-392"><a href="#Presto-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> +</span><span id="Presto-393"><a href="#Presto-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> +</span><span id="Presto-394"><a href="#Presto-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> +</span><span id="Presto-395"><a href="#Presto-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> +</span><span id="Presto-396"><a href="#Presto-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> +</span><span id="Presto-397"><a href="#Presto-397"><span class="linenos">397</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Presto-398"><a href="#Presto-398"><span class="linenos">398</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Presto-399"><a href="#Presto-399"><span class="linenos">399</span></a> <span class="p">[</span> +</span><span id="Presto-400"><a href="#Presto-400"><span class="linenos">400</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> +</span><span id="Presto-401"><a href="#Presto-401"><span class="linenos">401</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="Presto-402"><a href="#Presto-402"><span class="linenos">402</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> +</span><span id="Presto-403"><a href="#Presto-403"><span class="linenos">403</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="Presto-404"><a href="#Presto-404"><span class="linenos">404</span></a> <span class="p">]</span> +</span><span id="Presto-405"><a href="#Presto-405"><span class="linenos">405</span></a> <span class="p">),</span> +</span><span id="Presto-406"><a href="#Presto-406"><span class="linenos">406</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> +</span><span id="Presto-407"><a href="#Presto-407"><span class="linenos">407</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> +</span><span id="Presto-408"><a href="#Presto-408"><span class="linenos">408</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">_str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> +</span><span id="Presto-409"><a href="#Presto-409"><span class="linenos">409</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SPLIT_TO_MAP"</span><span class="p">),</span> +</span><span id="Presto-410"><a href="#Presto-410"><span class="linenos">410</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> +</span><span id="Presto-411"><a href="#Presto-411"><span class="linenos">411</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-412"><a href="#Presto-412"><span class="linenos">412</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Presto-413"><a href="#Presto-413"><span class="linenos">413</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> +</span><span id="Presto-414"><a href="#Presto-414"><span class="linenos">414</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_unnest_sequence</span><span class="p">]),</span> +</span><span id="Presto-415"><a href="#Presto-415"><span class="linenos">415</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> +</span><span id="Presto-416"><a href="#Presto-416"><span class="linenos">416</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">,</span> +</span><span id="Presto-417"><a href="#Presto-417"><span class="linenos">417</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="Presto-418"><a href="#Presto-418"><span class="linenos">418</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="Presto-419"><a href="#Presto-419"><span class="linenos">419</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-420"><a href="#Presto-420"><span class="linenos">420</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Presto-421"><a href="#Presto-421"><span class="linenos">421</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-422"><a href="#Presto-422"><span class="linenos">422</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-423"><a href="#Presto-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_UNIXTIME"</span><span class="p">),</span> +</span><span id="Presto-424"><a href="#Presto-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-425"><a href="#Presto-425"><span class="linenos">425</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-426"><a href="#Presto-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="Presto-427"><a href="#Presto-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-428"><a href="#Presto-428"><span class="linenos">428</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="Presto-429"><a href="#Presto-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="Presto-430"><a href="#Presto-430"><span class="linenos">430</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="Presto-431"><a href="#Presto-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> +</span><span id="Presto-432"><a href="#Presto-432"><span class="linenos">432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> +</span><span id="Presto-433"><a href="#Presto-433"><span class="linenos">433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-434"><a href="#Presto-434"><span class="linenos">434</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-435"><a href="#Presto-435"><span class="linenos">435</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="Presto-436"><a href="#Presto-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto-437"><a href="#Presto-437"><span class="linenos">437</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS VARCHAR)"</span><span class="p">,</span> +</span><span id="Presto-438"><a href="#Presto-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> +</span><span id="Presto-439"><a href="#Presto-439"><span class="linenos">439</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">add_recursive_cte_column_names</span><span class="p">]),</span> +</span><span id="Presto-440"><a href="#Presto-440"><span class="linenos">440</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Presto-441"><a href="#Presto-441"><span class="linenos">441</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> +</span><span id="Presto-442"><a href="#Presto-442"><span class="linenos">442</span></a> <span class="p">),</span> +</span><span id="Presto-443"><a href="#Presto-443"><span class="linenos">443</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</span><span class="p">,</span> +</span><span id="Presto-444"><a href="#Presto-444"><span class="linenos">444</span></a> <span class="p">}</span> +</span><span id="Presto-445"><a href="#Presto-445"><span class="linenos">445</span></a> +</span><span id="Presto-446"><a href="#Presto-446"><span class="linenos">446</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="Presto-447"><a href="#Presto-447"><span class="linenos">447</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="Presto-448"><a href="#Presto-448"><span class="linenos">448</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="Presto-449"><a href="#Presto-449"><span class="linenos">449</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">,</span> +</span><span id="Presto-450"><a href="#Presto-450"><span class="linenos">450</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto-451"><a href="#Presto-451"><span class="linenos">451</span></a> <span class="n">seq_get</span><span class="p">(</span> +</span><span id="Presto-452"><a href="#Presto-452"><span class="linenos">452</span></a> <span class="n">apply_index_offset</span><span class="p">(</span> +</span><span id="Presto-453"><a href="#Presto-453"><span class="linenos">453</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto-454"><a href="#Presto-454"><span class="linenos">454</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Presto-455"><a href="#Presto-455"><span class="linenos">455</span></a> <span class="mi">1</span> <span class="o">-</span> <span class="n">expression</span><span 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 class="mi">0</span><span class="p">),</span> +</span><span id="Presto-456"><a href="#Presto-456"><span class="linenos">456</span></a> <span class="p">),</span> +</span><span id="Presto-457"><a href="#Presto-457"><span class="linenos">457</span></a> <span class="mi">0</span><span class="p">,</span> +</span><span id="Presto-458"><a href="#Presto-458"><span class="linenos">458</span></a> <span class="p">),</span> +</span><span id="Presto-459"><a href="#Presto-459"><span class="linenos">459</span></a> <span class="p">)</span> +</span><span id="Presto-460"><a href="#Presto-460"><span class="linenos">460</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Presto-461"><a href="#Presto-461"><span class="linenos">461</span></a> +</span><span id="Presto-462"><a href="#Presto-462"><span class="linenos">462</span></a> <span class="k">def</span> <span class="nf">struct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto-463"><a href="#Presto-463"><span class="linenos">463</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEY_VALUE_DEFINITIONS</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="Presto-464"><a href="#Presto-464"><span class="linenos">464</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Struct with key-value definitions is unsupported."</span><span class="p">)</span> +</span><span id="Presto-465"><a href="#Presto-465"><span class="linenos">465</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="Presto-466"><a href="#Presto-466"><span class="linenos">466</span></a> -</span><span id="Presto-467"><a href="#Presto-467"><span class="linenos">467</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto-468"><a href="#Presto-468"><span class="linenos">468</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Presto-469"><a href="#Presto-469"><span class="linenos">469</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> -</span><span id="Presto-470"><a href="#Presto-470"><span class="linenos">470</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' DAY)"</span> -</span><span id="Presto-471"><a href="#Presto-471"><span class="linenos">471</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Presto-472"><a href="#Presto-472"><span class="linenos">472</span></a> -</span><span id="Presto-473"><a href="#Presto-473"><span class="linenos">473</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto-474"><a href="#Presto-474"><span class="linenos">474</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> -</span><span id="Presto-475"><a href="#Presto-475"><span class="linenos">475</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Presto-476"><a href="#Presto-476"><span class="linenos">476</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Presto-477"><a href="#Presto-477"><span class="linenos">477</span></a> -</span><span id="Presto-478"><a href="#Presto-478"><span class="linenos">478</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto-479"><a href="#Presto-479"><span class="linenos">479</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> -</span><span id="Presto-480"><a href="#Presto-480"><span class="linenos">480</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"end"</span><span class="p">]</span> -</span><span id="Presto-481"><a href="#Presto-481"><span class="linenos">481</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> -</span><span id="Presto-482"><a href="#Presto-482"><span class="linenos">482</span></a> -</span><span id="Presto-483"><a href="#Presto-483"><span class="linenos">483</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto-484"><a href="#Presto-484"><span class="linenos">484</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto-485"><a href="#Presto-485"><span class="linenos">485</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto-486"><a href="#Presto-486"><span class="linenos">486</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto-487"><a href="#Presto-487"><span class="linenos">487</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto-488"><a href="#Presto-488"><span class="linenos">488</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Presto-489"><a href="#Presto-489"><span class="linenos">489</span></a> -</span><span id="Presto-490"><a href="#Presto-490"><span class="linenos">490</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> -</span><span id="Presto-491"><a href="#Presto-491"><span class="linenos">491</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> -</span><span id="Presto-492"><a href="#Presto-492"><span class="linenos">492</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> -</span><span id="Presto-493"><a href="#Presto-493"><span class="linenos">493</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto-494"><a href="#Presto-494"><span class="linenos">494</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> -</span><span id="Presto-495"><a href="#Presto-495"><span class="linenos">495</span></a> -</span><span id="Presto-496"><a href="#Presto-496"><span class="linenos">496</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> +</span><span id="Presto-467"><a href="#Presto-467"><span class="linenos">467</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ROW"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Presto-468"><a href="#Presto-468"><span class="linenos">468</span></a> +</span><span id="Presto-469"><a href="#Presto-469"><span class="linenos">469</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto-470"><a href="#Presto-470"><span class="linenos">470</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Presto-471"><a href="#Presto-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> +</span><span id="Presto-472"><a href="#Presto-472"><span class="linenos">472</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' DAY)"</span> +</span><span id="Presto-473"><a href="#Presto-473"><span class="linenos">473</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Presto-474"><a href="#Presto-474"><span class="linenos">474</span></a> +</span><span id="Presto-475"><a href="#Presto-475"><span class="linenos">475</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto-476"><a href="#Presto-476"><span class="linenos">476</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> +</span><span id="Presto-477"><a href="#Presto-477"><span class="linenos">477</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Presto-478"><a href="#Presto-478"><span class="linenos">478</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Presto-479"><a href="#Presto-479"><span class="linenos">479</span></a> +</span><span id="Presto-480"><a href="#Presto-480"><span class="linenos">480</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto-481"><a href="#Presto-481"><span class="linenos">481</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> +</span><span id="Presto-482"><a href="#Presto-482"><span class="linenos">482</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"end"</span><span class="p">]</span> +</span><span id="Presto-483"><a href="#Presto-483"><span class="linenos">483</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> +</span><span id="Presto-484"><a href="#Presto-484"><span class="linenos">484</span></a> +</span><span id="Presto-485"><a href="#Presto-485"><span class="linenos">485</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto-486"><a href="#Presto-486"><span class="linenos">486</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto-487"><a href="#Presto-487"><span class="linenos">487</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto-488"><a href="#Presto-488"><span class="linenos">488</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto-489"><a href="#Presto-489"><span class="linenos">489</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto-490"><a href="#Presto-490"><span class="linenos">490</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Presto-491"><a href="#Presto-491"><span class="linenos">491</span></a> +</span><span id="Presto-492"><a href="#Presto-492"><span class="linenos">492</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> +</span><span id="Presto-493"><a href="#Presto-493"><span class="linenos">493</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> +</span><span id="Presto-494"><a href="#Presto-494"><span class="linenos">494</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> +</span><span id="Presto-495"><a href="#Presto-495"><span class="linenos">495</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto-496"><a href="#Presto-496"><span class="linenos">496</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> </span><span id="Presto-497"><a href="#Presto-497"><span class="linenos">497</span></a> -</span><span id="Presto-498"><a href="#Presto-498"><span class="linenos">498</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Presto-499"><a href="#Presto-499"><span class="linenos">499</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Presto-500"><a href="#Presto-500"><span class="linenos">500</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Presto-501"><a href="#Presto-501"><span class="linenos">501</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Presto-502"><a href="#Presto-502"><span class="linenos">502</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Presto-503"><a href="#Presto-503"><span class="linenos">503</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="Presto-504"><a href="#Presto-504"><span class="linenos">504</span></a> <span class="p">]</span> -</span><span id="Presto-505"><a href="#Presto-505"><span class="linenos">505</span></a> -</span><span id="Presto-506"><a href="#Presto-506"><span class="linenos">506</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto-507"><a href="#Presto-507"><span class="linenos">507</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Presto-508"><a href="#Presto-508"><span class="linenos">508</span></a><span class="sd"> Presto doesn't support CREATE VIEW with expressions (ex: `CREATE VIEW x (cola)` then `(cola)` is the expression),</span> -</span><span id="Presto-509"><a href="#Presto-509"><span class="linenos">509</span></a><span class="sd"> so we need to remove them</span> -</span><span id="Presto-510"><a href="#Presto-510"><span class="linenos">510</span></a><span class="sd"> """</span> -</span><span id="Presto-511"><a href="#Presto-511"><span class="linenos">511</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="Presto-512"><a href="#Presto-512"><span class="linenos">512</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Presto-513"><a href="#Presto-513"><span class="linenos">513</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"VIEW"</span> <span class="ow">and</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Presto-514"><a href="#Presto-514"><span class="linenos">514</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Presto-515"><a href="#Presto-515"><span class="linenos">515</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Presto-498"><a href="#Presto-498"><span class="linenos">498</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> +</span><span id="Presto-499"><a href="#Presto-499"><span class="linenos">499</span></a> +</span><span id="Presto-500"><a href="#Presto-500"><span class="linenos">500</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Presto-501"><a href="#Presto-501"><span class="linenos">501</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Presto-502"><a href="#Presto-502"><span class="linenos">502</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Presto-503"><a href="#Presto-503"><span class="linenos">503</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Presto-504"><a href="#Presto-504"><span class="linenos">504</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Presto-505"><a href="#Presto-505"><span class="linenos">505</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="Presto-506"><a href="#Presto-506"><span class="linenos">506</span></a> <span class="p">]</span> +</span><span id="Presto-507"><a href="#Presto-507"><span class="linenos">507</span></a> +</span><span id="Presto-508"><a href="#Presto-508"><span class="linenos">508</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto-509"><a href="#Presto-509"><span class="linenos">509</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Presto-510"><a href="#Presto-510"><span class="linenos">510</span></a><span class="sd"> Presto doesn't support CREATE VIEW with expressions (ex: `CREATE VIEW x (cola)` then `(cola)` is the expression),</span> +</span><span id="Presto-511"><a href="#Presto-511"><span class="linenos">511</span></a><span class="sd"> so we need to remove them</span> +</span><span id="Presto-512"><a href="#Presto-512"><span class="linenos">512</span></a><span class="sd"> """</span> +</span><span id="Presto-513"><a href="#Presto-513"><span class="linenos">513</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="Presto-514"><a href="#Presto-514"><span class="linenos">514</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Presto-515"><a href="#Presto-515"><span class="linenos">515</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"VIEW"</span> <span class="ow">and</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Presto-516"><a href="#Presto-516"><span class="linenos">516</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Presto-517"><a href="#Presto-517"><span class="linenos">517</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -1624,60 +1631,62 @@ True means <code>a / b</code> is integer division if both <code>a</code> and <co </div> <a class="headerlink" href="#Presto.Parser"></a> <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Parser-228"><a href="#Presto.Parser-228"><span class="linenos">228</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> -</span><span id="Presto.Parser-229"><a href="#Presto.Parser-229"><span class="linenos">229</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto.Parser-230"><a href="#Presto.Parser-230"><span class="linenos">230</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> -</span><span id="Presto.Parser-231"><a href="#Presto.Parser-231"><span class="linenos">231</span></a> <span class="s2">"ARBITRARY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-232"><a href="#Presto.Parser-232"><span class="linenos">232</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-233"><a href="#Presto.Parser-233"><span class="linenos">233</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> -</span><span id="Presto.Parser-234"><a href="#Presto.Parser-234"><span class="linenos">234</span></a> <span class="s2">"BITWISE_AND"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">),</span> -</span><span id="Presto.Parser-235"><a href="#Presto.Parser-235"><span class="linenos">235</span></a> <span class="s2">"BITWISE_NOT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> -</span><span id="Presto.Parser-236"><a href="#Presto.Parser-236"><span class="linenos">236</span></a> <span class="s2">"BITWISE_OR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">),</span> -</span><span id="Presto.Parser-237"><a href="#Presto.Parser-237"><span class="linenos">237</span></a> <span class="s2">"BITWISE_XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> -</span><span id="Presto.Parser-238"><a href="#Presto.Parser-238"><span class="linenos">238</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-239"><a href="#Presto.Parser-239"><span class="linenos">239</span></a> <span class="s2">"CONTAINS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-240"><a href="#Presto.Parser-240"><span class="linenos">240</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span> -</span><span id="Presto.Parser-241"><a href="#Presto.Parser-241"><span class="linenos">241</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="Presto.Parser-242"><a href="#Presto.Parser-242"><span class="linenos">242</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-243"><a href="#Presto.Parser-243"><span class="linenos">243</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span> -</span><span id="Presto.Parser-244"><a href="#Presto.Parser-244"><span class="linenos">244</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="Presto.Parser-245"><a href="#Presto.Parser-245"><span class="linenos">245</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-246"><a href="#Presto.Parser-246"><span class="linenos">246</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> -</span><span id="Presto.Parser-247"><a href="#Presto.Parser-247"><span class="linenos">247</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> -</span><span id="Presto.Parser-248"><a href="#Presto.Parser-248"><span class="linenos">248</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> -</span><span id="Presto.Parser-249"><a href="#Presto.Parser-249"><span class="linenos">249</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">(</span> -</span><span id="Presto.Parser-250"><a href="#Presto.Parser-250"><span class="linenos">250</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)],</span> <span class="n">offset</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="kc">True</span> -</span><span id="Presto.Parser-251"><a href="#Presto.Parser-251"><span class="linenos">251</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-252"><a href="#Presto.Parser-252"><span class="linenos">252</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-253"><a href="#Presto.Parser-253"><span class="linenos">253</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> -</span><span id="Presto.Parser-254"><a href="#Presto.Parser-254"><span class="linenos">254</span></a> <span class="s2">"FROM_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> -</span><span id="Presto.Parser-255"><a href="#Presto.Parser-255"><span class="linenos">255</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">replace</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="Presto.Parser-256"><a href="#Presto.Parser-256"><span class="linenos">256</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-257"><a href="#Presto.Parser-257"><span class="linenos">257</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-258"><a href="#Presto.Parser-258"><span class="linenos">258</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> -</span><span id="Presto.Parser-259"><a href="#Presto.Parser-259"><span class="linenos">259</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">group</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> -</span><span id="Presto.Parser-260"><a href="#Presto.Parser-260"><span class="linenos">260</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-261"><a href="#Presto.Parser-261"><span class="linenos">261</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> -</span><span id="Presto.Parser-262"><a href="#Presto.Parser-262"><span class="linenos">262</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> -</span><span id="Presto.Parser-263"><a href="#Presto.Parser-263"><span class="linenos">263</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> -</span><span id="Presto.Parser-264"><a href="#Presto.Parser-264"><span class="linenos">264</span></a> <span class="n">replacement</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">),</span> -</span><span id="Presto.Parser-265"><a href="#Presto.Parser-265"><span class="linenos">265</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-266"><a href="#Presto.Parser-266"><span class="linenos">266</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-267"><a href="#Presto.Parser-267"><span class="linenos">267</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-268"><a href="#Presto.Parser-268"><span class="linenos">268</span></a> <span class="s2">"SET_AGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-269"><a href="#Presto.Parser-269"><span class="linenos">269</span></a> <span class="s2">"SPLIT_TO_MAP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-270"><a href="#Presto.Parser-270"><span class="linenos">270</span></a> <span class="s2">"STRPOS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> -</span><span id="Presto.Parser-271"><a href="#Presto.Parser-271"><span class="linenos">271</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">substr</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">instance</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> -</span><span id="Presto.Parser-272"><a href="#Presto.Parser-272"><span class="linenos">272</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-273"><a href="#Presto.Parser-273"><span class="linenos">273</span></a> <span class="s2">"TO_CHAR"</span><span class="p">:</span> <span class="n">_parse_to_char</span><span class="p">,</span> -</span><span id="Presto.Parser-274"><a href="#Presto.Parser-274"><span class="linenos">274</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-275"><a href="#Presto.Parser-275"><span class="linenos">275</span></a> <span class="s2">"TO_UNIXTIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-276"><a href="#Presto.Parser-276"><span class="linenos">276</span></a> <span class="s2">"TO_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> -</span><span id="Presto.Parser-277"><a href="#Presto.Parser-277"><span class="linenos">277</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="Presto.Parser-278"><a href="#Presto.Parser-278"><span class="linenos">278</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-279"><a href="#Presto.Parser-279"><span class="linenos">279</span></a> <span class="p">}</span> -</span><span id="Presto.Parser-280"><a href="#Presto.Parser-280"><span class="linenos">280</span></a> -</span><span id="Presto.Parser-281"><a href="#Presto.Parser-281"><span class="linenos">281</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Presto.Parser-282"><a href="#Presto.Parser-282"><span class="linenos">282</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="Presto.Parser-229"><a href="#Presto.Parser-229"><span class="linenos">229</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Parser-230"><a href="#Presto.Parser-230"><span class="linenos">230</span></a> +</span><span id="Presto.Parser-231"><a href="#Presto.Parser-231"><span class="linenos">231</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto.Parser-232"><a href="#Presto.Parser-232"><span class="linenos">232</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> +</span><span id="Presto.Parser-233"><a href="#Presto.Parser-233"><span class="linenos">233</span></a> <span class="s2">"ARBITRARY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-234"><a href="#Presto.Parser-234"><span class="linenos">234</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-235"><a href="#Presto.Parser-235"><span class="linenos">235</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> +</span><span id="Presto.Parser-236"><a href="#Presto.Parser-236"><span class="linenos">236</span></a> <span class="s2">"BITWISE_AND"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">),</span> +</span><span id="Presto.Parser-237"><a href="#Presto.Parser-237"><span class="linenos">237</span></a> <span class="s2">"BITWISE_NOT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> +</span><span id="Presto.Parser-238"><a href="#Presto.Parser-238"><span class="linenos">238</span></a> <span class="s2">"BITWISE_OR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">),</span> +</span><span id="Presto.Parser-239"><a href="#Presto.Parser-239"><span class="linenos">239</span></a> <span class="s2">"BITWISE_XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> +</span><span id="Presto.Parser-240"><a href="#Presto.Parser-240"><span class="linenos">240</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-241"><a href="#Presto.Parser-241"><span class="linenos">241</span></a> <span class="s2">"CONTAINS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-242"><a href="#Presto.Parser-242"><span class="linenos">242</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span> +</span><span id="Presto.Parser-243"><a href="#Presto.Parser-243"><span class="linenos">243</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="Presto.Parser-244"><a href="#Presto.Parser-244"><span class="linenos">244</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-245"><a href="#Presto.Parser-245"><span class="linenos">245</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span> +</span><span id="Presto.Parser-246"><a href="#Presto.Parser-246"><span class="linenos">246</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="Presto.Parser-247"><a href="#Presto.Parser-247"><span class="linenos">247</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-248"><a href="#Presto.Parser-248"><span class="linenos">248</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> +</span><span id="Presto.Parser-249"><a href="#Presto.Parser-249"><span class="linenos">249</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"presto"</span><span class="p">),</span> +</span><span id="Presto.Parser-250"><a href="#Presto.Parser-250"><span class="linenos">250</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> +</span><span id="Presto.Parser-251"><a href="#Presto.Parser-251"><span class="linenos">251</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">(</span> +</span><span id="Presto.Parser-252"><a href="#Presto.Parser-252"><span class="linenos">252</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)],</span> <span class="n">offset</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="kc">True</span> +</span><span id="Presto.Parser-253"><a href="#Presto.Parser-253"><span class="linenos">253</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-254"><a href="#Presto.Parser-254"><span class="linenos">254</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-255"><a href="#Presto.Parser-255"><span class="linenos">255</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> +</span><span id="Presto.Parser-256"><a href="#Presto.Parser-256"><span class="linenos">256</span></a> <span class="s2">"FROM_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> +</span><span id="Presto.Parser-257"><a href="#Presto.Parser-257"><span class="linenos">257</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">replace</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="Presto.Parser-258"><a href="#Presto.Parser-258"><span class="linenos">258</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-259"><a href="#Presto.Parser-259"><span class="linenos">259</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-260"><a href="#Presto.Parser-260"><span class="linenos">260</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> +</span><span id="Presto.Parser-261"><a href="#Presto.Parser-261"><span class="linenos">261</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">group</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +</span><span id="Presto.Parser-262"><a href="#Presto.Parser-262"><span class="linenos">262</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-263"><a href="#Presto.Parser-263"><span class="linenos">263</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> +</span><span id="Presto.Parser-264"><a href="#Presto.Parser-264"><span class="linenos">264</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> +</span><span id="Presto.Parser-265"><a href="#Presto.Parser-265"><span class="linenos">265</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> +</span><span id="Presto.Parser-266"><a href="#Presto.Parser-266"><span class="linenos">266</span></a> <span class="n">replacement</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">),</span> +</span><span id="Presto.Parser-267"><a href="#Presto.Parser-267"><span class="linenos">267</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-268"><a href="#Presto.Parser-268"><span class="linenos">268</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-269"><a href="#Presto.Parser-269"><span class="linenos">269</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-270"><a href="#Presto.Parser-270"><span class="linenos">270</span></a> <span class="s2">"SET_AGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-271"><a href="#Presto.Parser-271"><span class="linenos">271</span></a> <span class="s2">"SPLIT_TO_MAP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-272"><a href="#Presto.Parser-272"><span class="linenos">272</span></a> <span class="s2">"STRPOS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> +</span><span id="Presto.Parser-273"><a href="#Presto.Parser-273"><span class="linenos">273</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">substr</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">instance</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +</span><span id="Presto.Parser-274"><a href="#Presto.Parser-274"><span class="linenos">274</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-275"><a href="#Presto.Parser-275"><span class="linenos">275</span></a> <span class="s2">"TO_CHAR"</span><span class="p">:</span> <span class="n">_parse_to_char</span><span class="p">,</span> +</span><span id="Presto.Parser-276"><a href="#Presto.Parser-276"><span class="linenos">276</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-277"><a href="#Presto.Parser-277"><span class="linenos">277</span></a> <span class="s2">"TO_UNIXTIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-278"><a href="#Presto.Parser-278"><span class="linenos">278</span></a> <span class="s2">"TO_UTF8"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> +</span><span id="Presto.Parser-279"><a href="#Presto.Parser-279"><span class="linenos">279</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="Presto.Parser-280"><a href="#Presto.Parser-280"><span class="linenos">280</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-281"><a href="#Presto.Parser-281"><span class="linenos">281</span></a> <span class="p">}</span> +</span><span id="Presto.Parser-282"><a href="#Presto.Parser-282"><span class="linenos">282</span></a> +</span><span id="Presto.Parser-283"><a href="#Presto.Parser-283"><span class="linenos">283</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Presto.Parser-284"><a href="#Presto.Parser-284"><span class="linenos">284</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> </span></pre></div> @@ -1698,6 +1707,18 @@ Default: 3</li> </div> + <div id="Presto.Parser.VALUES_FOLLOWED_BY_PAREN" class="classattr"> + <div class="attr variable"> + <span class="name">VALUES_FOLLOWED_BY_PAREN</span> = +<span class="default_value">False</span> + + + </div> + <a class="headerlink" href="#Presto.Parser.VALUES_FOLLOWED_BY_PAREN"></a> + + + + </div> <div id="Presto.Parser.FUNCTIONS" class="classattr"> <div class="attr variable"> <span class="name">FUNCTIONS</span> = @@ -1728,7 +1749,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">TABLE_ALIAS_TOKENS</span> = <input id="Presto.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="Presto.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.UPDATE: 'UPDATE'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.TEXT: 'TEXT'>, <TokenType.UINT: 'UINT'>, <TokenType.DELETE: 'DELETE'>, <TokenType.TOP: 'TOP'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.NEXT: 'NEXT'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.TABLE: 'TABLE'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.VAR: 'VAR'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.ANY: 'ANY'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.END: 'END'>, <TokenType.ALL: 'ALL'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.NESTED: 'NESTED'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.JSON: 'JSON'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.ANTI: 'ANTI'>, <TokenType.JSONB: 'JSONB'>, <TokenType.ROW: 'ROW'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SEMI: 'SEMI'>, <TokenType.RANGE: 'RANGE'>, <TokenType.SET: 'SET'>, <TokenType.IS: 'IS'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.BIT: 'BIT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.INT256: 'INT256'>, <TokenType.FALSE: 'FALSE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.ASC: 'ASC'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.SHOW: 'SHOW'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.NULL: 'NULL'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.DIV: 'DIV'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.CASE: 'CASE'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.FIRST: 'FIRST'>, <TokenType.YEAR: 'YEAR'>, <TokenType.UINT256: 'UINT256'>, <TokenType.MODEL: 'MODEL'>, <TokenType.UINT128: 'UINT128'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.BINARY: 'BINARY'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.USE: 'USE'>, <TokenType.TIME: 'TIME'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.LOAD: 'LOAD'>, <TokenType.CACHE: 'CACHE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.IPV6: 'IPV6'>, <TokenType.INT: 'INT'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.SOME: 'SOME'>, <TokenType.SUPER: 'SUPER'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.KILL: 'KILL'>, <TokenType.DATE: 'DATE'>, <TokenType.DESC: 'DESC'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.MAP: 'MAP'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.IPV4: 'IPV4'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UUID: 'UUID'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.ROWS: 'ROWS'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.INET: 'INET'>, <TokenType.FINAL: 'FINAL'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.DATE32: 'DATE32'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.INT128: 'INT128'>, <TokenType.MERGE: 'MERGE'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.XML: 'XML'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.STRUCT: 'STRUCT'>}</span> + <label class="view-value-button pdoc-button" for="Presto.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.BIT: 'BIT'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.FIRST: 'FIRST'>, <TokenType.RANGE: 'RANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.INT: 'INT'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.IS: 'IS'>, <TokenType.XML: 'XML'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.VAR: 'VAR'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.ROWS: 'ROWS'>, <TokenType.MERGE: 'MERGE'>, <TokenType.ANY: 'ANY'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.CACHE: 'CACHE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.INDEX: 'INDEX'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.FINAL: 'FINAL'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.USE: 'USE'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.IPV6: 'IPV6'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.ASC: 'ASC'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.BINARY: 'BINARY'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.DATE: 'DATE'>, <TokenType.SUPER: 'SUPER'>, <TokenType.TOP: 'TOP'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TEXT: 'TEXT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.SHOW: 'SHOW'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.SET: 'SET'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.MONEY: 'MONEY'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.NULL: 'NULL'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.NEXT: 'NEXT'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.ALL: 'ALL'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.ROW: 'ROW'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.TABLE: 'TABLE'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.CASE: 'CASE'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.MODEL: 'MODEL'>, <TokenType.YEAR: 'YEAR'>, <TokenType.IPV4: 'IPV4'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.INT256: 'INT256'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.INET: 'INET'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.MAP: 'MAP'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.UINT: 'UINT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.UINT256: 'UINT256'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.CHAR: 'CHAR'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.DIV: 'DIV'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UINT128: 'UINT128'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.DELETE: 'DELETE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.UUID: 'UUID'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.VIEW: 'VIEW'>, <TokenType.JSON: 'JSON'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.END: 'END'>, <TokenType.INT128: 'INT128'>, <TokenType.KILL: 'KILL'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.SEMI: 'SEMI'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.SOME: 'SOME'>, <TokenType.ANTI: 'ANTI'>, <TokenType.FALSE: 'FALSE'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.DESC: 'DESC'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.UPDATE: 'UPDATE'>}</span> </div> @@ -1877,238 +1898,238 @@ Default: 3</li> </div> <a class="headerlink" href="#Presto.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator-284"><a href="#Presto.Generator-284"><span class="linenos">284</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="Presto.Generator-285"><a href="#Presto.Generator-285"><span class="linenos">285</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-286"><a href="#Presto.Generator-286"><span class="linenos">286</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-287"><a href="#Presto.Generator-287"><span class="linenos">287</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-288"><a href="#Presto.Generator-288"><span class="linenos">288</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-289"><a href="#Presto.Generator-289"><span class="linenos">289</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-290"><a href="#Presto.Generator-290"><span class="linenos">290</span></a> <span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Presto.Generator-291"><a href="#Presto.Generator-291"><span class="linenos">291</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-292"><a href="#Presto.Generator-292"><span class="linenos">292</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="Presto.Generator-293"><a href="#Presto.Generator-293"><span class="linenos">293</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Presto.Generator-294"><a href="#Presto.Generator-294"><span class="linenos">294</span></a> <span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-295"><a href="#Presto.Generator-295"><span class="linenos">295</span></a> <span class="n">LIKE_PROPERTY_INSIDE_SCHEMA</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Presto.Generator-296"><a href="#Presto.Generator-296"><span class="linenos">296</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-297"><a href="#Presto.Generator-297"><span class="linenos">297</span></a> -</span><span id="Presto.Generator-298"><a href="#Presto.Generator-298"><span class="linenos">298</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto.Generator-299"><a href="#Presto.Generator-299"><span class="linenos">299</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Presto.Generator-300"><a href="#Presto.Generator-300"><span class="linenos">300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Presto.Generator-301"><a href="#Presto.Generator-301"><span class="linenos">301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Presto.Generator-302"><a href="#Presto.Generator-302"><span class="linenos">302</span></a> <span class="p">}</span> -</span><span id="Presto.Generator-303"><a href="#Presto.Generator-303"><span class="linenos">303</span></a> -</span><span id="Presto.Generator-304"><a href="#Presto.Generator-304"><span class="linenos">304</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto.Generator-305"><a href="#Presto.Generator-305"><span class="linenos">305</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="Presto.Generator-306"><a href="#Presto.Generator-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="Presto.Generator-307"><a href="#Presto.Generator-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="Presto.Generator-308"><a href="#Presto.Generator-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> -</span><span id="Presto.Generator-309"><a href="#Presto.Generator-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="Presto.Generator-310"><a href="#Presto.Generator-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> -</span><span id="Presto.Generator-311"><a href="#Presto.Generator-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto.Generator-312"><a href="#Presto.Generator-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> -</span><span id="Presto.Generator-313"><a href="#Presto.Generator-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto.Generator-314"><a href="#Presto.Generator-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto.Generator-315"><a href="#Presto.Generator-315"><span class="linenos">315</span></a> <span class="p">}</span> -</span><span id="Presto.Generator-316"><a href="#Presto.Generator-316"><span class="linenos">316</span></a> -</span><span id="Presto.Generator-317"><a href="#Presto.Generator-317"><span class="linenos">317</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto.Generator-318"><a href="#Presto.Generator-318"><span class="linenos">318</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="Presto.Generator-319"><a href="#Presto.Generator-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARBITRARY"</span><span class="p">),</span> -</span><span id="Presto.Generator-320"><a href="#Presto.Generator-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-321"><a href="#Presto.Generator-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> -</span><span id="Presto.Generator-322"><a href="#Presto.Generator-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> -</span><span id="Presto.Generator-323"><a href="#Presto.Generator-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> -</span><span id="Presto.Generator-324"><a href="#Presto.Generator-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"ARRAY[</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">]"</span><span class="p">,</span> -</span><span id="Presto.Generator-325"><a href="#Presto.Generator-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> -</span><span id="Presto.Generator-326"><a href="#Presto.Generator-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> -</span><span id="Presto.Generator-327"><a href="#Presto.Generator-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> -</span><span id="Presto.Generator-328"><a href="#Presto.Generator-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SET_AGG"</span><span class="p">),</span> -</span><span id="Presto.Generator-329"><a href="#Presto.Generator-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"AT_TIMEZONE"</span><span class="p">),</span> -</span><span id="Presto.Generator-330"><a href="#Presto.Generator-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-331"><a href="#Presto.Generator-331"><span class="linenos">331</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_AND(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-332"><a href="#Presto.Generator-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-333"><a href="#Presto.Generator-333"><span class="linenos">333</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-334"><a href="#Presto.Generator-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-335"><a href="#Presto.Generator-335"><span class="linenos">335</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-336"><a href="#Presto.Generator-336"><span class="linenos">336</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_OR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-337"><a href="#Presto.Generator-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-338"><a href="#Presto.Generator-338"><span class="linenos">338</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-339"><a href="#Presto.Generator-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-340"><a href="#Presto.Generator-340"><span class="linenos">340</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_XOR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-341"><a href="#Presto.Generator-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="Presto.Generator-342"><a href="#Presto.Generator-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto.Generator-343"><a href="#Presto.Generator-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Presto.Generator-344"><a href="#Presto.Generator-344"><span class="linenos">344</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> -</span><span id="Presto.Generator-345"><a href="#Presto.Generator-345"><span class="linenos">345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> -</span><span id="Presto.Generator-346"><a href="#Presto.Generator-346"><span class="linenos">346</span></a> <span class="n">_to_int</span><span class="p">(</span> -</span><span id="Presto.Generator-347"><a href="#Presto.Generator-347"><span class="linenos">347</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Presto.Generator-348"><a href="#Presto.Generator-348"><span class="linenos">348</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-349"><a href="#Presto.Generator-349"><span class="linenos">349</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto.Generator-350"><a href="#Presto.Generator-350"><span class="linenos">350</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-351"><a href="#Presto.Generator-351"><span class="linenos">351</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Presto.Generator-352"><a href="#Presto.Generator-352"><span class="linenos">352</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="Presto.Generator-353"><a href="#Presto.Generator-353"><span class="linenos">353</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-354"><a href="#Presto.Generator-354"><span class="linenos">354</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="Presto.Generator-355"><a href="#Presto.Generator-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-356"><a href="#Presto.Generator-356"><span class="linenos">356</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> -</span><span id="Presto.Generator-357"><a href="#Presto.Generator-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Presto.Generator-358"><a href="#Presto.Generator-358"><span class="linenos">358</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> -</span><span id="Presto.Generator-359"><a href="#Presto.Generator-359"><span class="linenos">359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> -</span><span id="Presto.Generator-360"><a href="#Presto.Generator-360"><span class="linenos">360</span></a> <span class="n">_to_int</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span> <span class="o">*</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> -</span><span id="Presto.Generator-361"><a href="#Presto.Generator-361"><span class="linenos">361</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto.Generator-362"><a href="#Presto.Generator-362"><span class="linenos">362</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-363"><a href="#Presto.Generator-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"FROM_UTF8"</span><span class="p">),</span> -</span><span id="Presto.Generator-364"><a href="#Presto.Generator-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-365"><a href="#Presto.Generator-365"><span class="linenos">365</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> -</span><span id="Presto.Generator-366"><a href="#Presto.Generator-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"TO_UTF8"</span><span class="p">),</span> -</span><span id="Presto.Generator-367"><a href="#Presto.Generator-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"FORMAT='</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> -</span><span id="Presto.Generator-368"><a href="#Presto.Generator-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">First</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-369"><a href="#Presto.Generator-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FirstValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-370"><a href="#Presto.Generator-370"><span class="linenos">370</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><span id="Presto.Generator-371"><a href="#Presto.Generator-371"><span class="linenos">371</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"WITH_TIMEZONE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'zone'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AT TIME ZONE 'UTC'"</span><span class="p">,</span> -</span><span id="Presto.Generator-372"><a href="#Presto.Generator-372"><span class="linenos">372</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unalias_group</span><span class="p">]),</span> -</span><span id="Presto.Generator-373"><a href="#Presto.Generator-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Presto.Generator-374"><a href="#Presto.Generator-374"><span class="linenos">374</span></a> <span class="s2">"ARRAY_JOIN"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ARRAY_AGG"</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">"separator"</span><span class="p">)</span> -</span><span id="Presto.Generator-375"><a href="#Presto.Generator-375"><span class="linenos">375</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-376"><a href="#Presto.Generator-376"><span class="linenos">376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> -</span><span id="Presto.Generator-377"><a href="#Presto.Generator-377"><span class="linenos">377</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(),</span> -</span><span id="Presto.Generator-378"><a href="#Presto.Generator-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-379"><a href="#Presto.Generator-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-380"><a href="#Presto.Generator-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"JSON_PARSE"</span><span class="p">),</span> -</span><span id="Presto.Generator-381"><a href="#Presto.Generator-381"><span class="linenos">381</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Last</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-382"><a href="#Presto.Generator-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-383"><a href="#Presto.Generator-383"><span class="linenos">383</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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">"LAST_DAY_OF_MONTH"</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="Presto.Generator-384"><a href="#Presto.Generator-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-385"><a href="#Presto.Generator-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-386"><a href="#Presto.Generator-386"><span class="linenos">386</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> -</span><span id="Presto.Generator-387"><a href="#Presto.Generator-387"><span class="linenos">387</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> -</span><span id="Presto.Generator-388"><a href="#Presto.Generator-388"><span class="linenos">388</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> -</span><span id="Presto.Generator-389"><a href="#Presto.Generator-389"><span class="linenos">389</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-390"><a href="#Presto.Generator-390"><span class="linenos">390</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-391"><a href="#Presto.Generator-391"><span class="linenos">391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-392"><a href="#Presto.Generator-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-393"><a href="#Presto.Generator-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-394"><a href="#Presto.Generator-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-395"><a href="#Presto.Generator-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Presto.Generator-396"><a href="#Presto.Generator-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Presto.Generator-397"><a href="#Presto.Generator-397"><span class="linenos">397</span></a> <span class="p">[</span> -</span><span id="Presto.Generator-398"><a href="#Presto.Generator-398"><span class="linenos">398</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> -</span><span id="Presto.Generator-399"><a href="#Presto.Generator-399"><span class="linenos">399</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="Presto.Generator-400"><a href="#Presto.Generator-400"><span class="linenos">400</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> -</span><span id="Presto.Generator-401"><a href="#Presto.Generator-401"><span class="linenos">401</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="Presto.Generator-402"><a href="#Presto.Generator-402"><span class="linenos">402</span></a> <span class="p">]</span> -</span><span id="Presto.Generator-403"><a href="#Presto.Generator-403"><span class="linenos">403</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-404"><a href="#Presto.Generator-404"><span class="linenos">404</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> -</span><span id="Presto.Generator-405"><a href="#Presto.Generator-405"><span class="linenos">405</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> -</span><span id="Presto.Generator-406"><a href="#Presto.Generator-406"><span class="linenos">406</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">_str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> -</span><span id="Presto.Generator-407"><a href="#Presto.Generator-407"><span class="linenos">407</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SPLIT_TO_MAP"</span><span class="p">),</span> -</span><span id="Presto.Generator-408"><a href="#Presto.Generator-408"><span class="linenos">408</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-409"><a href="#Presto.Generator-409"><span class="linenos">409</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-410"><a href="#Presto.Generator-410"><span class="linenos">410</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Presto.Generator-411"><a href="#Presto.Generator-411"><span class="linenos">411</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-412"><a href="#Presto.Generator-412"><span class="linenos">412</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_unnest_sequence</span><span class="p">]),</span> -</span><span id="Presto.Generator-413"><a href="#Presto.Generator-413"><span class="linenos">413</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-414"><a href="#Presto.Generator-414"><span class="linenos">414</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-415"><a href="#Presto.Generator-415"><span class="linenos">415</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-416"><a href="#Presto.Generator-416"><span class="linenos">416</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-417"><a href="#Presto.Generator-417"><span class="linenos">417</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-418"><a href="#Presto.Generator-418"><span class="linenos">418</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Presto.Generator-419"><a href="#Presto.Generator-419"><span class="linenos">419</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-420"><a href="#Presto.Generator-420"><span class="linenos">420</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-421"><a href="#Presto.Generator-421"><span class="linenos">421</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_UNIXTIME"</span><span class="p">),</span> -</span><span id="Presto.Generator-422"><a href="#Presto.Generator-422"><span class="linenos">422</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-423"><a href="#Presto.Generator-423"><span class="linenos">423</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-424"><a href="#Presto.Generator-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="Presto.Generator-425"><a href="#Presto.Generator-425"><span class="linenos">425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-426"><a href="#Presto.Generator-426"><span class="linenos">426</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> -</span><span id="Presto.Generator-427"><a href="#Presto.Generator-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-428"><a href="#Presto.Generator-428"><span class="linenos">428</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="Presto.Generator-429"><a href="#Presto.Generator-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-430"><a href="#Presto.Generator-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> -</span><span id="Presto.Generator-431"><a href="#Presto.Generator-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-432"><a href="#Presto.Generator-432"><span class="linenos">432</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-433"><a href="#Presto.Generator-433"><span class="linenos">433</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="Presto.Generator-434"><a href="#Presto.Generator-434"><span class="linenos">434</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Presto.Generator-435"><a href="#Presto.Generator-435"><span class="linenos">435</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS VARCHAR)"</span><span class="p">,</span> -</span><span id="Presto.Generator-436"><a href="#Presto.Generator-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> -</span><span id="Presto.Generator-437"><a href="#Presto.Generator-437"><span class="linenos">437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">add_recursive_cte_column_names</span><span class="p">]),</span> -</span><span id="Presto.Generator-438"><a href="#Presto.Generator-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Presto.Generator-439"><a href="#Presto.Generator-439"><span class="linenos">439</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> -</span><span id="Presto.Generator-440"><a href="#Presto.Generator-440"><span class="linenos">440</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-441"><a href="#Presto.Generator-441"><span class="linenos">441</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-442"><a href="#Presto.Generator-442"><span class="linenos">442</span></a> <span class="p">}</span> -</span><span id="Presto.Generator-443"><a href="#Presto.Generator-443"><span class="linenos">443</span></a> -</span><span id="Presto.Generator-444"><a href="#Presto.Generator-444"><span class="linenos">444</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="Presto.Generator-445"><a href="#Presto.Generator-445"><span class="linenos">445</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="Presto.Generator-446"><a href="#Presto.Generator-446"><span class="linenos">446</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="Presto.Generator-447"><a href="#Presto.Generator-447"><span class="linenos">447</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">,</span> -</span><span id="Presto.Generator-448"><a href="#Presto.Generator-448"><span class="linenos">448</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto.Generator-449"><a href="#Presto.Generator-449"><span class="linenos">449</span></a> <span class="n">seq_get</span><span class="p">(</span> -</span><span id="Presto.Generator-450"><a href="#Presto.Generator-450"><span class="linenos">450</span></a> <span class="n">apply_index_offset</span><span class="p">(</span> -</span><span id="Presto.Generator-451"><a href="#Presto.Generator-451"><span class="linenos">451</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto.Generator-452"><a href="#Presto.Generator-452"><span class="linenos">452</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Presto.Generator-453"><a href="#Presto.Generator-453"><span class="linenos">453</span></a> <span class="mi">1</span> <span class="o">-</span> <span class="n">expression</span><span 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 class="mi">0</span><span class="p">),</span> -</span><span id="Presto.Generator-454"><a href="#Presto.Generator-454"><span class="linenos">454</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-455"><a href="#Presto.Generator-455"><span class="linenos">455</span></a> <span class="mi">0</span><span class="p">,</span> -</span><span id="Presto.Generator-456"><a href="#Presto.Generator-456"><span class="linenos">456</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-457"><a href="#Presto.Generator-457"><span class="linenos">457</span></a> <span class="p">)</span> -</span><span id="Presto.Generator-458"><a href="#Presto.Generator-458"><span class="linenos">458</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Presto.Generator-459"><a href="#Presto.Generator-459"><span class="linenos">459</span></a> -</span><span id="Presto.Generator-460"><a href="#Presto.Generator-460"><span class="linenos">460</span></a> <span class="k">def</span> <span class="nf">struct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator-461"><a href="#Presto.Generator-461"><span class="linenos">461</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEY_VALUE_DEFINITIONS</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="Presto.Generator-462"><a href="#Presto.Generator-462"><span class="linenos">462</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Struct with key-value definitions is unsupported."</span><span class="p">)</span> -</span><span id="Presto.Generator-463"><a href="#Presto.Generator-463"><span class="linenos">463</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Presto.Generator-464"><a href="#Presto.Generator-464"><span class="linenos">464</span></a> -</span><span id="Presto.Generator-465"><a href="#Presto.Generator-465"><span class="linenos">465</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ROW"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator-286"><a href="#Presto.Generator-286"><span class="linenos">286</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="Presto.Generator-287"><a href="#Presto.Generator-287"><span class="linenos">287</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-288"><a href="#Presto.Generator-288"><span class="linenos">288</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-289"><a href="#Presto.Generator-289"><span class="linenos">289</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-290"><a href="#Presto.Generator-290"><span class="linenos">290</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-291"><a href="#Presto.Generator-291"><span class="linenos">291</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-292"><a href="#Presto.Generator-292"><span class="linenos">292</span></a> <span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Presto.Generator-293"><a href="#Presto.Generator-293"><span class="linenos">293</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-294"><a href="#Presto.Generator-294"><span class="linenos">294</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="Presto.Generator-295"><a href="#Presto.Generator-295"><span class="linenos">295</span></a> <span class="n">LIMIT_ONLY_LITERALS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Presto.Generator-296"><a href="#Presto.Generator-296"><span class="linenos">296</span></a> <span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-297"><a href="#Presto.Generator-297"><span class="linenos">297</span></a> <span class="n">LIKE_PROPERTY_INSIDE_SCHEMA</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Presto.Generator-298"><a href="#Presto.Generator-298"><span class="linenos">298</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-299"><a href="#Presto.Generator-299"><span class="linenos">299</span></a> +</span><span id="Presto.Generator-300"><a href="#Presto.Generator-300"><span class="linenos">300</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto.Generator-301"><a href="#Presto.Generator-301"><span class="linenos">301</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Presto.Generator-302"><a href="#Presto.Generator-302"><span class="linenos">302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Presto.Generator-303"><a href="#Presto.Generator-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Presto.Generator-304"><a href="#Presto.Generator-304"><span class="linenos">304</span></a> <span class="p">}</span> +</span><span id="Presto.Generator-305"><a href="#Presto.Generator-305"><span class="linenos">305</span></a> +</span><span id="Presto.Generator-306"><a href="#Presto.Generator-306"><span class="linenos">306</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto.Generator-307"><a href="#Presto.Generator-307"><span class="linenos">307</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="Presto.Generator-308"><a href="#Presto.Generator-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="Presto.Generator-309"><a href="#Presto.Generator-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="Presto.Generator-310"><a href="#Presto.Generator-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> +</span><span id="Presto.Generator-311"><a href="#Presto.Generator-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="Presto.Generator-312"><a href="#Presto.Generator-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> +</span><span id="Presto.Generator-313"><a href="#Presto.Generator-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto.Generator-314"><a href="#Presto.Generator-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> +</span><span id="Presto.Generator-315"><a href="#Presto.Generator-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto.Generator-316"><a href="#Presto.Generator-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto.Generator-317"><a href="#Presto.Generator-317"><span class="linenos">317</span></a> <span class="p">}</span> +</span><span id="Presto.Generator-318"><a href="#Presto.Generator-318"><span class="linenos">318</span></a> +</span><span id="Presto.Generator-319"><a href="#Presto.Generator-319"><span class="linenos">319</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto.Generator-320"><a href="#Presto.Generator-320"><span class="linenos">320</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="Presto.Generator-321"><a href="#Presto.Generator-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARBITRARY"</span><span class="p">),</span> +</span><span id="Presto.Generator-322"><a href="#Presto.Generator-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-323"><a href="#Presto.Generator-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> +</span><span id="Presto.Generator-324"><a href="#Presto.Generator-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> +</span><span id="Presto.Generator-325"><a href="#Presto.Generator-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> +</span><span id="Presto.Generator-326"><a href="#Presto.Generator-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"ARRAY[</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">]"</span><span class="p">,</span> +</span><span id="Presto.Generator-327"><a href="#Presto.Generator-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> +</span><span id="Presto.Generator-328"><a href="#Presto.Generator-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> +</span><span id="Presto.Generator-329"><a href="#Presto.Generator-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> +</span><span id="Presto.Generator-330"><a href="#Presto.Generator-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayUniqueAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SET_AGG"</span><span class="p">),</span> +</span><span id="Presto.Generator-331"><a href="#Presto.Generator-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"AT_TIMEZONE"</span><span class="p">),</span> +</span><span id="Presto.Generator-332"><a href="#Presto.Generator-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-333"><a href="#Presto.Generator-333"><span class="linenos">333</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_AND(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-334"><a href="#Presto.Generator-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-335"><a href="#Presto.Generator-335"><span class="linenos">335</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-336"><a href="#Presto.Generator-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-337"><a href="#Presto.Generator-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-338"><a href="#Presto.Generator-338"><span class="linenos">338</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_OR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-339"><a href="#Presto.Generator-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-340"><a href="#Presto.Generator-340"><span class="linenos">340</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-341"><a href="#Presto.Generator-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-342"><a href="#Presto.Generator-342"><span class="linenos">342</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"BITWISE_XOR(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-343"><a href="#Presto.Generator-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="Presto.Generator-344"><a href="#Presto.Generator-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto.Generator-345"><a href="#Presto.Generator-345"><span class="linenos">345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Presto.Generator-346"><a href="#Presto.Generator-346"><span class="linenos">346</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> +</span><span id="Presto.Generator-347"><a href="#Presto.Generator-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> +</span><span id="Presto.Generator-348"><a href="#Presto.Generator-348"><span class="linenos">348</span></a> <span class="n">_to_int</span><span class="p">(</span> +</span><span id="Presto.Generator-349"><a href="#Presto.Generator-349"><span class="linenos">349</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Presto.Generator-350"><a href="#Presto.Generator-350"><span class="linenos">350</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-351"><a href="#Presto.Generator-351"><span class="linenos">351</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto.Generator-352"><a href="#Presto.Generator-352"><span class="linenos">352</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-353"><a href="#Presto.Generator-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Presto.Generator-354"><a href="#Presto.Generator-354"><span class="linenos">354</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> +</span><span id="Presto.Generator-355"><a href="#Presto.Generator-355"><span class="linenos">355</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-356"><a href="#Presto.Generator-356"><span class="linenos">356</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="Presto.Generator-357"><a href="#Presto.Generator-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-358"><a href="#Presto.Generator-358"><span class="linenos">358</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> +</span><span id="Presto.Generator-359"><a href="#Presto.Generator-359"><span class="linenos">359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Presto.Generator-360"><a href="#Presto.Generator-360"><span class="linenos">360</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> +</span><span id="Presto.Generator-361"><a href="#Presto.Generator-361"><span class="linenos">361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> +</span><span id="Presto.Generator-362"><a href="#Presto.Generator-362"><span class="linenos">362</span></a> <span class="n">_to_int</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span> <span class="o">*</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> +</span><span id="Presto.Generator-363"><a href="#Presto.Generator-363"><span class="linenos">363</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto.Generator-364"><a href="#Presto.Generator-364"><span class="linenos">364</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-365"><a href="#Presto.Generator-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"FROM_UTF8"</span><span class="p">),</span> +</span><span id="Presto.Generator-366"><a href="#Presto.Generator-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-367"><a href="#Presto.Generator-367"><span class="linenos">367</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> +</span><span id="Presto.Generator-368"><a href="#Presto.Generator-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"TO_UTF8"</span><span class="p">),</span> +</span><span id="Presto.Generator-369"><a href="#Presto.Generator-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"FORMAT='</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> +</span><span id="Presto.Generator-370"><a href="#Presto.Generator-370"><span class="linenos">370</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">First</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-371"><a href="#Presto.Generator-371"><span class="linenos">371</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FirstValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-372"><a href="#Presto.Generator-372"><span class="linenos">372</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><span id="Presto.Generator-373"><a href="#Presto.Generator-373"><span class="linenos">373</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"WITH_TIMEZONE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'zone'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AT TIME ZONE 'UTC'"</span><span class="p">,</span> +</span><span id="Presto.Generator-374"><a href="#Presto.Generator-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unalias_group</span><span class="p">]),</span> +</span><span id="Presto.Generator-375"><a href="#Presto.Generator-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Presto.Generator-376"><a href="#Presto.Generator-376"><span class="linenos">376</span></a> <span class="s2">"ARRAY_JOIN"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ARRAY_AGG"</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">"separator"</span><span class="p">)</span> +</span><span id="Presto.Generator-377"><a href="#Presto.Generator-377"><span class="linenos">377</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-378"><a href="#Presto.Generator-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> +</span><span id="Presto.Generator-379"><a href="#Presto.Generator-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">(),</span> +</span><span id="Presto.Generator-380"><a href="#Presto.Generator-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-381"><a href="#Presto.Generator-381"><span class="linenos">381</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-382"><a href="#Presto.Generator-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"JSON_PARSE"</span><span class="p">),</span> +</span><span id="Presto.Generator-383"><a href="#Presto.Generator-383"><span class="linenos">383</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Last</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-384"><a href="#Presto.Generator-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastValue</span><span class="p">:</span> <span class="n">_first_last_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-385"><a href="#Presto.Generator-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span 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">"LAST_DAY_OF_MONTH"</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="Presto.Generator-386"><a href="#Presto.Generator-386"><span class="linenos">386</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-387"><a href="#Presto.Generator-387"><span class="linenos">387</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-388"><a href="#Presto.Generator-388"><span class="linenos">388</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> +</span><span id="Presto.Generator-389"><a href="#Presto.Generator-389"><span class="linenos">389</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> +</span><span id="Presto.Generator-390"><a href="#Presto.Generator-390"><span class="linenos">390</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> +</span><span id="Presto.Generator-391"><a href="#Presto.Generator-391"><span class="linenos">391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-392"><a href="#Presto.Generator-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-393"><a href="#Presto.Generator-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-394"><a href="#Presto.Generator-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-395"><a href="#Presto.Generator-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-396"><a href="#Presto.Generator-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-397"><a href="#Presto.Generator-397"><span class="linenos">397</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Presto.Generator-398"><a href="#Presto.Generator-398"><span class="linenos">398</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Presto.Generator-399"><a href="#Presto.Generator-399"><span class="linenos">399</span></a> <span class="p">[</span> +</span><span id="Presto.Generator-400"><a href="#Presto.Generator-400"><span class="linenos">400</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> +</span><span id="Presto.Generator-401"><a href="#Presto.Generator-401"><span class="linenos">401</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="Presto.Generator-402"><a href="#Presto.Generator-402"><span class="linenos">402</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> +</span><span id="Presto.Generator-403"><a href="#Presto.Generator-403"><span class="linenos">403</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="Presto.Generator-404"><a href="#Presto.Generator-404"><span class="linenos">404</span></a> <span class="p">]</span> +</span><span id="Presto.Generator-405"><a href="#Presto.Generator-405"><span class="linenos">405</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-406"><a href="#Presto.Generator-406"><span class="linenos">406</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> +</span><span id="Presto.Generator-407"><a href="#Presto.Generator-407"><span class="linenos">407</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> +</span><span id="Presto.Generator-408"><a href="#Presto.Generator-408"><span class="linenos">408</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">_str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> +</span><span id="Presto.Generator-409"><a href="#Presto.Generator-409"><span class="linenos">409</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SPLIT_TO_MAP"</span><span class="p">),</span> +</span><span id="Presto.Generator-410"><a href="#Presto.Generator-410"><span class="linenos">410</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-411"><a href="#Presto.Generator-411"><span class="linenos">411</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-412"><a href="#Presto.Generator-412"><span class="linenos">412</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Presto.Generator-413"><a href="#Presto.Generator-413"><span class="linenos">413</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-414"><a href="#Presto.Generator-414"><span class="linenos">414</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">_unnest_sequence</span><span class="p">]),</span> +</span><span id="Presto.Generator-415"><a href="#Presto.Generator-415"><span class="linenos">415</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-416"><a href="#Presto.Generator-416"><span class="linenos">416</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-417"><a href="#Presto.Generator-417"><span class="linenos">417</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-418"><a href="#Presto.Generator-418"><span class="linenos">418</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-419"><a href="#Presto.Generator-419"><span class="linenos">419</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-420"><a href="#Presto.Generator-420"><span class="linenos">420</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Presto.Generator-421"><a href="#Presto.Generator-421"><span class="linenos">421</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-422"><a href="#Presto.Generator-422"><span class="linenos">422</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-423"><a href="#Presto.Generator-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_UNIXTIME"</span><span class="p">),</span> +</span><span id="Presto.Generator-424"><a href="#Presto.Generator-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-425"><a href="#Presto.Generator-425"><span class="linenos">425</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-426"><a href="#Presto.Generator-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="Presto.Generator-427"><a href="#Presto.Generator-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-428"><a href="#Presto.Generator-428"><span class="linenos">428</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="Presto.Generator-429"><a href="#Presto.Generator-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-430"><a href="#Presto.Generator-430"><span class="linenos">430</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="Presto.Generator-431"><a href="#Presto.Generator-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-432"><a href="#Presto.Generator-432"><span class="linenos">432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> +</span><span id="Presto.Generator-433"><a href="#Presto.Generator-433"><span class="linenos">433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-434"><a href="#Presto.Generator-434"><span class="linenos">434</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-435"><a href="#Presto.Generator-435"><span class="linenos">435</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="Presto.Generator-436"><a href="#Presto.Generator-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Presto.Generator-437"><a href="#Presto.Generator-437"><span class="linenos">437</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(FROM_UNIXTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS VARCHAR)"</span><span class="p">,</span> +</span><span id="Presto.Generator-438"><a href="#Presto.Generator-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> +</span><span id="Presto.Generator-439"><a href="#Presto.Generator-439"><span class="linenos">439</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">add_recursive_cte_column_names</span><span class="p">]),</span> +</span><span id="Presto.Generator-440"><a href="#Presto.Generator-440"><span class="linenos">440</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Presto.Generator-441"><a href="#Presto.Generator-441"><span class="linenos">441</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> +</span><span id="Presto.Generator-442"><a href="#Presto.Generator-442"><span class="linenos">442</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-443"><a href="#Presto.Generator-443"><span class="linenos">443</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-444"><a href="#Presto.Generator-444"><span class="linenos">444</span></a> <span class="p">}</span> +</span><span id="Presto.Generator-445"><a href="#Presto.Generator-445"><span class="linenos">445</span></a> +</span><span id="Presto.Generator-446"><a href="#Presto.Generator-446"><span class="linenos">446</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="Presto.Generator-447"><a href="#Presto.Generator-447"><span class="linenos">447</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="Presto.Generator-448"><a href="#Presto.Generator-448"><span class="linenos">448</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="Presto.Generator-449"><a href="#Presto.Generator-449"><span class="linenos">449</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">,</span> +</span><span id="Presto.Generator-450"><a href="#Presto.Generator-450"><span class="linenos">450</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto.Generator-451"><a href="#Presto.Generator-451"><span class="linenos">451</span></a> <span class="n">seq_get</span><span class="p">(</span> +</span><span id="Presto.Generator-452"><a href="#Presto.Generator-452"><span class="linenos">452</span></a> <span class="n">apply_index_offset</span><span class="p">(</span> +</span><span id="Presto.Generator-453"><a href="#Presto.Generator-453"><span class="linenos">453</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto.Generator-454"><a href="#Presto.Generator-454"><span class="linenos">454</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Presto.Generator-455"><a href="#Presto.Generator-455"><span class="linenos">455</span></a> <span class="mi">1</span> <span class="o">-</span> <span class="n">expression</span><span 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 class="mi">0</span><span class="p">),</span> +</span><span id="Presto.Generator-456"><a href="#Presto.Generator-456"><span class="linenos">456</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-457"><a href="#Presto.Generator-457"><span class="linenos">457</span></a> <span class="mi">0</span><span class="p">,</span> +</span><span id="Presto.Generator-458"><a href="#Presto.Generator-458"><span class="linenos">458</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-459"><a href="#Presto.Generator-459"><span class="linenos">459</span></a> <span class="p">)</span> +</span><span id="Presto.Generator-460"><a href="#Presto.Generator-460"><span class="linenos">460</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Presto.Generator-461"><a href="#Presto.Generator-461"><span class="linenos">461</span></a> +</span><span id="Presto.Generator-462"><a href="#Presto.Generator-462"><span class="linenos">462</span></a> <span class="k">def</span> <span class="nf">struct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator-463"><a href="#Presto.Generator-463"><span class="linenos">463</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEY_VALUE_DEFINITIONS</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="Presto.Generator-464"><a href="#Presto.Generator-464"><span class="linenos">464</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Struct with key-value definitions is unsupported."</span><span class="p">)</span> +</span><span id="Presto.Generator-465"><a href="#Presto.Generator-465"><span class="linenos">465</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="Presto.Generator-466"><a href="#Presto.Generator-466"><span class="linenos">466</span></a> -</span><span id="Presto.Generator-467"><a href="#Presto.Generator-467"><span class="linenos">467</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator-468"><a href="#Presto.Generator-468"><span class="linenos">468</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Presto.Generator-469"><a href="#Presto.Generator-469"><span class="linenos">469</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> -</span><span id="Presto.Generator-470"><a href="#Presto.Generator-470"><span class="linenos">470</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' DAY)"</span> -</span><span id="Presto.Generator-471"><a href="#Presto.Generator-471"><span class="linenos">471</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Presto.Generator-472"><a href="#Presto.Generator-472"><span class="linenos">472</span></a> -</span><span id="Presto.Generator-473"><a href="#Presto.Generator-473"><span class="linenos">473</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator-474"><a href="#Presto.Generator-474"><span class="linenos">474</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> -</span><span id="Presto.Generator-475"><a href="#Presto.Generator-475"><span class="linenos">475</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Presto.Generator-476"><a href="#Presto.Generator-476"><span class="linenos">476</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Presto.Generator-477"><a href="#Presto.Generator-477"><span class="linenos">477</span></a> -</span><span id="Presto.Generator-478"><a href="#Presto.Generator-478"><span class="linenos">478</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator-479"><a href="#Presto.Generator-479"><span class="linenos">479</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> -</span><span id="Presto.Generator-480"><a href="#Presto.Generator-480"><span class="linenos">480</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"end"</span><span class="p">]</span> -</span><span id="Presto.Generator-481"><a href="#Presto.Generator-481"><span class="linenos">481</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> -</span><span id="Presto.Generator-482"><a href="#Presto.Generator-482"><span class="linenos">482</span></a> -</span><span id="Presto.Generator-483"><a href="#Presto.Generator-483"><span class="linenos">483</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto.Generator-484"><a href="#Presto.Generator-484"><span class="linenos">484</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto.Generator-485"><a href="#Presto.Generator-485"><span class="linenos">485</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto.Generator-486"><a href="#Presto.Generator-486"><span class="linenos">486</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto.Generator-487"><a href="#Presto.Generator-487"><span class="linenos">487</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto.Generator-488"><a href="#Presto.Generator-488"><span class="linenos">488</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Presto.Generator-489"><a href="#Presto.Generator-489"><span class="linenos">489</span></a> -</span><span id="Presto.Generator-490"><a href="#Presto.Generator-490"><span class="linenos">490</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> -</span><span id="Presto.Generator-491"><a href="#Presto.Generator-491"><span class="linenos">491</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> -</span><span id="Presto.Generator-492"><a href="#Presto.Generator-492"><span class="linenos">492</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> -</span><span id="Presto.Generator-493"><a href="#Presto.Generator-493"><span class="linenos">493</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto.Generator-494"><a href="#Presto.Generator-494"><span class="linenos">494</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> -</span><span id="Presto.Generator-495"><a href="#Presto.Generator-495"><span class="linenos">495</span></a> -</span><span id="Presto.Generator-496"><a href="#Presto.Generator-496"><span class="linenos">496</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> +</span><span id="Presto.Generator-467"><a href="#Presto.Generator-467"><span class="linenos">467</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ROW"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Presto.Generator-468"><a href="#Presto.Generator-468"><span class="linenos">468</span></a> +</span><span id="Presto.Generator-469"><a href="#Presto.Generator-469"><span class="linenos">469</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator-470"><a href="#Presto.Generator-470"><span class="linenos">470</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Presto.Generator-471"><a href="#Presto.Generator-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> +</span><span id="Presto.Generator-472"><a href="#Presto.Generator-472"><span class="linenos">472</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' DAY)"</span> +</span><span id="Presto.Generator-473"><a href="#Presto.Generator-473"><span class="linenos">473</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Presto.Generator-474"><a href="#Presto.Generator-474"><span class="linenos">474</span></a> +</span><span id="Presto.Generator-475"><a href="#Presto.Generator-475"><span class="linenos">475</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator-476"><a href="#Presto.Generator-476"><span class="linenos">476</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> +</span><span id="Presto.Generator-477"><a href="#Presto.Generator-477"><span class="linenos">477</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Presto.Generator-478"><a href="#Presto.Generator-478"><span class="linenos">478</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Presto.Generator-479"><a href="#Presto.Generator-479"><span class="linenos">479</span></a> +</span><span id="Presto.Generator-480"><a href="#Presto.Generator-480"><span class="linenos">480</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator-481"><a href="#Presto.Generator-481"><span class="linenos">481</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> +</span><span id="Presto.Generator-482"><a href="#Presto.Generator-482"><span class="linenos">482</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"end"</span><span class="p">]</span> +</span><span id="Presto.Generator-483"><a href="#Presto.Generator-483"><span class="linenos">483</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> +</span><span id="Presto.Generator-484"><a href="#Presto.Generator-484"><span class="linenos">484</span></a> +</span><span id="Presto.Generator-485"><a href="#Presto.Generator-485"><span class="linenos">485</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto.Generator-486"><a href="#Presto.Generator-486"><span class="linenos">486</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto.Generator-487"><a href="#Presto.Generator-487"><span class="linenos">487</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto.Generator-488"><a href="#Presto.Generator-488"><span class="linenos">488</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto.Generator-489"><a href="#Presto.Generator-489"><span class="linenos">489</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto.Generator-490"><a href="#Presto.Generator-490"><span class="linenos">490</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Presto.Generator-491"><a href="#Presto.Generator-491"><span class="linenos">491</span></a> +</span><span id="Presto.Generator-492"><a href="#Presto.Generator-492"><span class="linenos">492</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> +</span><span id="Presto.Generator-493"><a href="#Presto.Generator-493"><span class="linenos">493</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> +</span><span id="Presto.Generator-494"><a href="#Presto.Generator-494"><span class="linenos">494</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> +</span><span id="Presto.Generator-495"><a href="#Presto.Generator-495"><span class="linenos">495</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto.Generator-496"><a href="#Presto.Generator-496"><span class="linenos">496</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> </span><span id="Presto.Generator-497"><a href="#Presto.Generator-497"><span class="linenos">497</span></a> -</span><span id="Presto.Generator-498"><a href="#Presto.Generator-498"><span class="linenos">498</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Presto.Generator-499"><a href="#Presto.Generator-499"><span class="linenos">499</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Presto.Generator-500"><a href="#Presto.Generator-500"><span class="linenos">500</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Presto.Generator-501"><a href="#Presto.Generator-501"><span class="linenos">501</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Presto.Generator-502"><a href="#Presto.Generator-502"><span class="linenos">502</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Presto.Generator-503"><a href="#Presto.Generator-503"><span class="linenos">503</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="Presto.Generator-504"><a href="#Presto.Generator-504"><span class="linenos">504</span></a> <span class="p">]</span> -</span><span id="Presto.Generator-505"><a href="#Presto.Generator-505"><span class="linenos">505</span></a> -</span><span id="Presto.Generator-506"><a href="#Presto.Generator-506"><span class="linenos">506</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator-507"><a href="#Presto.Generator-507"><span class="linenos">507</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Presto.Generator-508"><a href="#Presto.Generator-508"><span class="linenos">508</span></a><span class="sd"> Presto doesn't support CREATE VIEW with expressions (ex: `CREATE VIEW x (cola)` then `(cola)` is the expression),</span> -</span><span id="Presto.Generator-509"><a href="#Presto.Generator-509"><span class="linenos">509</span></a><span class="sd"> so we need to remove them</span> -</span><span id="Presto.Generator-510"><a href="#Presto.Generator-510"><span class="linenos">510</span></a><span class="sd"> """</span> -</span><span id="Presto.Generator-511"><a href="#Presto.Generator-511"><span class="linenos">511</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="Presto.Generator-512"><a href="#Presto.Generator-512"><span class="linenos">512</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Presto.Generator-513"><a href="#Presto.Generator-513"><span class="linenos">513</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"VIEW"</span> <span class="ow">and</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Presto.Generator-514"><a href="#Presto.Generator-514"><span class="linenos">514</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Presto.Generator-515"><a href="#Presto.Generator-515"><span class="linenos">515</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Presto.Generator-498"><a href="#Presto.Generator-498"><span class="linenos">498</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> +</span><span id="Presto.Generator-499"><a href="#Presto.Generator-499"><span class="linenos">499</span></a> +</span><span id="Presto.Generator-500"><a href="#Presto.Generator-500"><span class="linenos">500</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Presto.Generator-501"><a href="#Presto.Generator-501"><span class="linenos">501</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Presto.Generator-502"><a href="#Presto.Generator-502"><span class="linenos">502</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Presto.Generator-503"><a href="#Presto.Generator-503"><span class="linenos">503</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Presto.Generator-504"><a href="#Presto.Generator-504"><span class="linenos">504</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Presto.Generator-505"><a href="#Presto.Generator-505"><span class="linenos">505</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="Presto.Generator-506"><a href="#Presto.Generator-506"><span class="linenos">506</span></a> <span class="p">]</span> +</span><span id="Presto.Generator-507"><a href="#Presto.Generator-507"><span class="linenos">507</span></a> +</span><span id="Presto.Generator-508"><a href="#Presto.Generator-508"><span class="linenos">508</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator-509"><a href="#Presto.Generator-509"><span class="linenos">509</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Presto.Generator-510"><a href="#Presto.Generator-510"><span class="linenos">510</span></a><span class="sd"> Presto doesn't support CREATE VIEW with expressions (ex: `CREATE VIEW x (cola)` then `(cola)` is the expression),</span> +</span><span id="Presto.Generator-511"><a href="#Presto.Generator-511"><span class="linenos">511</span></a><span class="sd"> so we need to remove them</span> +</span><span id="Presto.Generator-512"><a href="#Presto.Generator-512"><span class="linenos">512</span></a><span class="sd"> """</span> +</span><span id="Presto.Generator-513"><a href="#Presto.Generator-513"><span class="linenos">513</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="Presto.Generator-514"><a href="#Presto.Generator-514"><span class="linenos">514</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Presto.Generator-515"><a href="#Presto.Generator-515"><span class="linenos">515</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"VIEW"</span> <span class="ow">and</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Presto.Generator-516"><a href="#Presto.Generator-516"><span class="linenos">516</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Presto.Generator-517"><a href="#Presto.Generator-517"><span class="linenos">517</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2345,21 +2366,21 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.bracket_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.bracket_sql-444"><a href="#Presto.Generator.bracket_sql-444"><span class="linenos">444</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="Presto.Generator.bracket_sql-445"><a href="#Presto.Generator.bracket_sql-445"><span class="linenos">445</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="Presto.Generator.bracket_sql-446"><a href="#Presto.Generator.bracket_sql-446"><span class="linenos">446</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="Presto.Generator.bracket_sql-447"><a href="#Presto.Generator.bracket_sql-447"><span class="linenos">447</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">,</span> -</span><span id="Presto.Generator.bracket_sql-448"><a href="#Presto.Generator.bracket_sql-448"><span class="linenos">448</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto.Generator.bracket_sql-449"><a href="#Presto.Generator.bracket_sql-449"><span class="linenos">449</span></a> <span class="n">seq_get</span><span class="p">(</span> -</span><span id="Presto.Generator.bracket_sql-450"><a href="#Presto.Generator.bracket_sql-450"><span class="linenos">450</span></a> <span class="n">apply_index_offset</span><span class="p">(</span> -</span><span id="Presto.Generator.bracket_sql-451"><a href="#Presto.Generator.bracket_sql-451"><span class="linenos">451</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Presto.Generator.bracket_sql-452"><a href="#Presto.Generator.bracket_sql-452"><span class="linenos">452</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Presto.Generator.bracket_sql-453"><a href="#Presto.Generator.bracket_sql-453"><span class="linenos">453</span></a> <span class="mi">1</span> <span class="o">-</span> <span class="n">expression</span><span 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 class="mi">0</span><span class="p">),</span> -</span><span id="Presto.Generator.bracket_sql-454"><a href="#Presto.Generator.bracket_sql-454"><span class="linenos">454</span></a> <span class="p">),</span> -</span><span id="Presto.Generator.bracket_sql-455"><a href="#Presto.Generator.bracket_sql-455"><span class="linenos">455</span></a> <span class="mi">0</span><span class="p">,</span> -</span><span id="Presto.Generator.bracket_sql-456"><a href="#Presto.Generator.bracket_sql-456"><span class="linenos">456</span></a> <span class="p">),</span> -</span><span id="Presto.Generator.bracket_sql-457"><a href="#Presto.Generator.bracket_sql-457"><span class="linenos">457</span></a> <span class="p">)</span> -</span><span id="Presto.Generator.bracket_sql-458"><a href="#Presto.Generator.bracket_sql-458"><span class="linenos">458</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.bracket_sql-446"><a href="#Presto.Generator.bracket_sql-446"><span class="linenos">446</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="Presto.Generator.bracket_sql-447"><a href="#Presto.Generator.bracket_sql-447"><span class="linenos">447</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="Presto.Generator.bracket_sql-448"><a href="#Presto.Generator.bracket_sql-448"><span class="linenos">448</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="Presto.Generator.bracket_sql-449"><a href="#Presto.Generator.bracket_sql-449"><span class="linenos">449</span></a> <span class="s2">"ELEMENT_AT"</span><span class="p">,</span> +</span><span id="Presto.Generator.bracket_sql-450"><a href="#Presto.Generator.bracket_sql-450"><span class="linenos">450</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto.Generator.bracket_sql-451"><a href="#Presto.Generator.bracket_sql-451"><span class="linenos">451</span></a> <span class="n">seq_get</span><span class="p">(</span> +</span><span id="Presto.Generator.bracket_sql-452"><a href="#Presto.Generator.bracket_sql-452"><span class="linenos">452</span></a> <span class="n">apply_index_offset</span><span class="p">(</span> +</span><span id="Presto.Generator.bracket_sql-453"><a href="#Presto.Generator.bracket_sql-453"><span class="linenos">453</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Presto.Generator.bracket_sql-454"><a href="#Presto.Generator.bracket_sql-454"><span class="linenos">454</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Presto.Generator.bracket_sql-455"><a href="#Presto.Generator.bracket_sql-455"><span class="linenos">455</span></a> <span class="mi">1</span> <span class="o">-</span> <span class="n">expression</span><span 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 class="mi">0</span><span class="p">),</span> +</span><span id="Presto.Generator.bracket_sql-456"><a href="#Presto.Generator.bracket_sql-456"><span class="linenos">456</span></a> <span class="p">),</span> +</span><span id="Presto.Generator.bracket_sql-457"><a href="#Presto.Generator.bracket_sql-457"><span class="linenos">457</span></a> <span class="mi">0</span><span class="p">,</span> +</span><span id="Presto.Generator.bracket_sql-458"><a href="#Presto.Generator.bracket_sql-458"><span class="linenos">458</span></a> <span class="p">),</span> +</span><span id="Presto.Generator.bracket_sql-459"><a href="#Presto.Generator.bracket_sql-459"><span class="linenos">459</span></a> <span class="p">)</span> +</span><span id="Presto.Generator.bracket_sql-460"><a href="#Presto.Generator.bracket_sql-460"><span class="linenos">460</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2377,12 +2398,12 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.struct_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.struct_sql-460"><a href="#Presto.Generator.struct_sql-460"><span class="linenos">460</span></a> <span class="k">def</span> <span class="nf">struct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator.struct_sql-461"><a href="#Presto.Generator.struct_sql-461"><span class="linenos">461</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEY_VALUE_DEFINITIONS</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="Presto.Generator.struct_sql-462"><a href="#Presto.Generator.struct_sql-462"><span class="linenos">462</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Struct with key-value definitions is unsupported."</span><span class="p">)</span> -</span><span id="Presto.Generator.struct_sql-463"><a href="#Presto.Generator.struct_sql-463"><span class="linenos">463</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Presto.Generator.struct_sql-464"><a href="#Presto.Generator.struct_sql-464"><span class="linenos">464</span></a> -</span><span id="Presto.Generator.struct_sql-465"><a href="#Presto.Generator.struct_sql-465"><span class="linenos">465</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ROW"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.struct_sql-462"><a href="#Presto.Generator.struct_sql-462"><span class="linenos">462</span></a> <span class="k">def</span> <span class="nf">struct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator.struct_sql-463"><a href="#Presto.Generator.struct_sql-463"><span class="linenos">463</span></a> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEY_VALUE_DEFINITIONS</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="Presto.Generator.struct_sql-464"><a href="#Presto.Generator.struct_sql-464"><span class="linenos">464</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Struct with key-value definitions is unsupported."</span><span class="p">)</span> +</span><span id="Presto.Generator.struct_sql-465"><a href="#Presto.Generator.struct_sql-465"><span class="linenos">465</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Presto.Generator.struct_sql-466"><a href="#Presto.Generator.struct_sql-466"><span class="linenos">466</span></a> +</span><span id="Presto.Generator.struct_sql-467"><a href="#Presto.Generator.struct_sql-467"><span class="linenos">467</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ROW"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2400,11 +2421,11 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.interval_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.interval_sql-467"><a href="#Presto.Generator.interval_sql-467"><span class="linenos">467</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator.interval_sql-468"><a href="#Presto.Generator.interval_sql-468"><span class="linenos">468</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Presto.Generator.interval_sql-469"><a href="#Presto.Generator.interval_sql-469"><span class="linenos">469</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> -</span><span id="Presto.Generator.interval_sql-470"><a href="#Presto.Generator.interval_sql-470"><span class="linenos">470</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' DAY)"</span> -</span><span id="Presto.Generator.interval_sql-471"><a href="#Presto.Generator.interval_sql-471"><span class="linenos">471</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.interval_sql-469"><a href="#Presto.Generator.interval_sql-469"><span class="linenos">469</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator.interval_sql-470"><a href="#Presto.Generator.interval_sql-470"><span class="linenos">470</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Presto.Generator.interval_sql-471"><a href="#Presto.Generator.interval_sql-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> +</span><span id="Presto.Generator.interval_sql-472"><a href="#Presto.Generator.interval_sql-472"><span class="linenos">472</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' DAY)"</span> +</span><span id="Presto.Generator.interval_sql-473"><a href="#Presto.Generator.interval_sql-473"><span class="linenos">473</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2422,10 +2443,10 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.transaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.transaction_sql-473"><a href="#Presto.Generator.transaction_sql-473"><span class="linenos">473</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator.transaction_sql-474"><a href="#Presto.Generator.transaction_sql-474"><span class="linenos">474</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> -</span><span id="Presto.Generator.transaction_sql-475"><a href="#Presto.Generator.transaction_sql-475"><span class="linenos">475</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Presto.Generator.transaction_sql-476"><a href="#Presto.Generator.transaction_sql-476"><span class="linenos">476</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.transaction_sql-475"><a href="#Presto.Generator.transaction_sql-475"><span class="linenos">475</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator.transaction_sql-476"><a href="#Presto.Generator.transaction_sql-476"><span class="linenos">476</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> +</span><span id="Presto.Generator.transaction_sql-477"><a href="#Presto.Generator.transaction_sql-477"><span class="linenos">477</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Presto.Generator.transaction_sql-478"><a href="#Presto.Generator.transaction_sql-478"><span class="linenos">478</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -2443,25 +2464,25 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.generateseries_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.generateseries_sql-478"><a href="#Presto.Generator.generateseries_sql-478"><span class="linenos">478</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator.generateseries_sql-479"><a href="#Presto.Generator.generateseries_sql-479"><span class="linenos">479</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> -</span><span id="Presto.Generator.generateseries_sql-480"><a href="#Presto.Generator.generateseries_sql-480"><span class="linenos">480</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"end"</span><span class="p">]</span> -</span><span id="Presto.Generator.generateseries_sql-481"><a href="#Presto.Generator.generateseries_sql-481"><span class="linenos">481</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> -</span><span id="Presto.Generator.generateseries_sql-482"><a href="#Presto.Generator.generateseries_sql-482"><span class="linenos">482</span></a> -</span><span id="Presto.Generator.generateseries_sql-483"><a href="#Presto.Generator.generateseries_sql-483"><span class="linenos">483</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto.Generator.generateseries_sql-484"><a href="#Presto.Generator.generateseries_sql-484"><span class="linenos">484</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto.Generator.generateseries_sql-485"><a href="#Presto.Generator.generateseries_sql-485"><span class="linenos">485</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto.Generator.generateseries_sql-486"><a href="#Presto.Generator.generateseries_sql-486"><span class="linenos">486</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto.Generator.generateseries_sql-487"><a href="#Presto.Generator.generateseries_sql-487"><span class="linenos">487</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto.Generator.generateseries_sql-488"><a href="#Presto.Generator.generateseries_sql-488"><span class="linenos">488</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Presto.Generator.generateseries_sql-489"><a href="#Presto.Generator.generateseries_sql-489"><span class="linenos">489</span></a> -</span><span id="Presto.Generator.generateseries_sql-490"><a href="#Presto.Generator.generateseries_sql-490"><span class="linenos">490</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> -</span><span id="Presto.Generator.generateseries_sql-491"><a href="#Presto.Generator.generateseries_sql-491"><span class="linenos">491</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> -</span><span id="Presto.Generator.generateseries_sql-492"><a href="#Presto.Generator.generateseries_sql-492"><span class="linenos">492</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> -</span><span id="Presto.Generator.generateseries_sql-493"><a href="#Presto.Generator.generateseries_sql-493"><span class="linenos">493</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto.Generator.generateseries_sql-494"><a href="#Presto.Generator.generateseries_sql-494"><span class="linenos">494</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> -</span><span id="Presto.Generator.generateseries_sql-495"><a href="#Presto.Generator.generateseries_sql-495"><span class="linenos">495</span></a> -</span><span id="Presto.Generator.generateseries_sql-496"><a href="#Presto.Generator.generateseries_sql-496"><span class="linenos">496</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.generateseries_sql-480"><a href="#Presto.Generator.generateseries_sql-480"><span class="linenos">480</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator.generateseries_sql-481"><a href="#Presto.Generator.generateseries_sql-481"><span class="linenos">481</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> +</span><span id="Presto.Generator.generateseries_sql-482"><a href="#Presto.Generator.generateseries_sql-482"><span class="linenos">482</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"end"</span><span class="p">]</span> +</span><span id="Presto.Generator.generateseries_sql-483"><a href="#Presto.Generator.generateseries_sql-483"><span class="linenos">483</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> +</span><span id="Presto.Generator.generateseries_sql-484"><a href="#Presto.Generator.generateseries_sql-484"><span class="linenos">484</span></a> +</span><span id="Presto.Generator.generateseries_sql-485"><a href="#Presto.Generator.generateseries_sql-485"><span class="linenos">485</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto.Generator.generateseries_sql-486"><a href="#Presto.Generator.generateseries_sql-486"><span class="linenos">486</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto.Generator.generateseries_sql-487"><a href="#Presto.Generator.generateseries_sql-487"><span class="linenos">487</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto.Generator.generateseries_sql-488"><a href="#Presto.Generator.generateseries_sql-488"><span class="linenos">488</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto.Generator.generateseries_sql-489"><a href="#Presto.Generator.generateseries_sql-489"><span class="linenos">489</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto.Generator.generateseries_sql-490"><a href="#Presto.Generator.generateseries_sql-490"><span class="linenos">490</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Presto.Generator.generateseries_sql-491"><a href="#Presto.Generator.generateseries_sql-491"><span class="linenos">491</span></a> +</span><span id="Presto.Generator.generateseries_sql-492"><a href="#Presto.Generator.generateseries_sql-492"><span class="linenos">492</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> +</span><span id="Presto.Generator.generateseries_sql-493"><a href="#Presto.Generator.generateseries_sql-493"><span class="linenos">493</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> +</span><span id="Presto.Generator.generateseries_sql-494"><a href="#Presto.Generator.generateseries_sql-494"><span class="linenos">494</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> +</span><span id="Presto.Generator.generateseries_sql-495"><a href="#Presto.Generator.generateseries_sql-495"><span class="linenos">495</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto.Generator.generateseries_sql-496"><a href="#Presto.Generator.generateseries_sql-496"><span class="linenos">496</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">target_type</span><span class="p">)</span> +</span><span id="Presto.Generator.generateseries_sql-497"><a href="#Presto.Generator.generateseries_sql-497"><span class="linenos">497</span></a> +</span><span id="Presto.Generator.generateseries_sql-498"><a href="#Presto.Generator.generateseries_sql-498"><span class="linenos">498</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> </span></pre></div> @@ -2479,13 +2500,13 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.offset_limit_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.offset_limit_modifiers-498"><a href="#Presto.Generator.offset_limit_modifiers-498"><span class="linenos">498</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Presto.Generator.offset_limit_modifiers-499"><a href="#Presto.Generator.offset_limit_modifiers-499"><span class="linenos">499</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Presto.Generator.offset_limit_modifiers-500"><a href="#Presto.Generator.offset_limit_modifiers-500"><span class="linenos">500</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Presto.Generator.offset_limit_modifiers-501"><a href="#Presto.Generator.offset_limit_modifiers-501"><span class="linenos">501</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Presto.Generator.offset_limit_modifiers-502"><a href="#Presto.Generator.offset_limit_modifiers-502"><span class="linenos">502</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Presto.Generator.offset_limit_modifiers-503"><a href="#Presto.Generator.offset_limit_modifiers-503"><span class="linenos">503</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="Presto.Generator.offset_limit_modifiers-504"><a href="#Presto.Generator.offset_limit_modifiers-504"><span class="linenos">504</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.offset_limit_modifiers-500"><a href="#Presto.Generator.offset_limit_modifiers-500"><span class="linenos">500</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Presto.Generator.offset_limit_modifiers-501"><a href="#Presto.Generator.offset_limit_modifiers-501"><span class="linenos">501</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Presto.Generator.offset_limit_modifiers-502"><a href="#Presto.Generator.offset_limit_modifiers-502"><span class="linenos">502</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Presto.Generator.offset_limit_modifiers-503"><a href="#Presto.Generator.offset_limit_modifiers-503"><span class="linenos">503</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Presto.Generator.offset_limit_modifiers-504"><a href="#Presto.Generator.offset_limit_modifiers-504"><span class="linenos">504</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Presto.Generator.offset_limit_modifiers-505"><a href="#Presto.Generator.offset_limit_modifiers-505"><span class="linenos">505</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="Presto.Generator.offset_limit_modifiers-506"><a href="#Presto.Generator.offset_limit_modifiers-506"><span class="linenos">506</span></a> <span class="p">]</span> </span></pre></div> @@ -2503,16 +2524,16 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.create_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.create_sql-506"><a href="#Presto.Generator.create_sql-506"><span class="linenos">506</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator.create_sql-507"><a href="#Presto.Generator.create_sql-507"><span class="linenos">507</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Presto.Generator.create_sql-508"><a href="#Presto.Generator.create_sql-508"><span class="linenos">508</span></a><span class="sd"> Presto doesn't support CREATE VIEW with expressions (ex: `CREATE VIEW x (cola)` then `(cola)` is the expression),</span> -</span><span id="Presto.Generator.create_sql-509"><a href="#Presto.Generator.create_sql-509"><span class="linenos">509</span></a><span class="sd"> so we need to remove them</span> -</span><span id="Presto.Generator.create_sql-510"><a href="#Presto.Generator.create_sql-510"><span class="linenos">510</span></a><span class="sd"> """</span> -</span><span id="Presto.Generator.create_sql-511"><a href="#Presto.Generator.create_sql-511"><span class="linenos">511</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="Presto.Generator.create_sql-512"><a href="#Presto.Generator.create_sql-512"><span class="linenos">512</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Presto.Generator.create_sql-513"><a href="#Presto.Generator.create_sql-513"><span class="linenos">513</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"VIEW"</span> <span class="ow">and</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Presto.Generator.create_sql-514"><a href="#Presto.Generator.create_sql-514"><span class="linenos">514</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Presto.Generator.create_sql-515"><a href="#Presto.Generator.create_sql-515"><span class="linenos">515</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.create_sql-508"><a href="#Presto.Generator.create_sql-508"><span class="linenos">508</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator.create_sql-509"><a href="#Presto.Generator.create_sql-509"><span class="linenos">509</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Presto.Generator.create_sql-510"><a href="#Presto.Generator.create_sql-510"><span class="linenos">510</span></a><span class="sd"> Presto doesn't support CREATE VIEW with expressions (ex: `CREATE VIEW x (cola)` then `(cola)` is the expression),</span> +</span><span id="Presto.Generator.create_sql-511"><a href="#Presto.Generator.create_sql-511"><span class="linenos">511</span></a><span class="sd"> so we need to remove them</span> +</span><span id="Presto.Generator.create_sql-512"><a href="#Presto.Generator.create_sql-512"><span class="linenos">512</span></a><span class="sd"> """</span> +</span><span id="Presto.Generator.create_sql-513"><a href="#Presto.Generator.create_sql-513"><span class="linenos">513</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="Presto.Generator.create_sql-514"><a href="#Presto.Generator.create_sql-514"><span class="linenos">514</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Presto.Generator.create_sql-515"><a href="#Presto.Generator.create_sql-515"><span class="linenos">515</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"VIEW"</span> <span class="ow">and</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Presto.Generator.create_sql-516"><a href="#Presto.Generator.create_sql-516"><span class="linenos">516</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Presto.Generator.create_sql-517"><a href="#Presto.Generator.create_sql-517"><span class="linenos">517</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> |