diff options
Diffstat (limited to 'docs/sqlglot/dialects/redshift.html')
-rw-r--r-- | docs/sqlglot/dialects/redshift.html | 1708 |
1 files changed, 877 insertions, 831 deletions
diff --git a/docs/sqlglot/dialects/redshift.html b/docs/sqlglot/dialects/redshift.html index 9e3103d..f23d4aa 100644 --- a/docs/sqlglot/dialects/redshift.html +++ b/docs/sqlglot/dialects/redshift.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> - <meta name="generator" content="pdoc 14.4.0"/> + <meta name="generator" content="pdoc 14.5.0"/> <title>sqlglot.dialects.redshift API documentation</title> <style>/*! * Bootstrap Reboot v5.0.0 (https://getbootstrap.com/) * Copyright 2011-2021 The Bootstrap Authors * Copyright 2011-2021 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) */*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;background-color:#fff;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important}</style> @@ -130,6 +130,9 @@ <a class="variable" href="#Redshift.Generator.HEX_FUNC">HEX_FUNC</a> </li> <li> + <a class="variable" href="#Redshift.Generator.WITH_PROPERTIES_PREFIX">WITH_PROPERTIES_PREFIX</a> + </li> + <li> <a class="variable" href="#Redshift.Generator.TYPE_MAPPING">TYPE_MAPPING</a> </li> <li> @@ -142,15 +145,15 @@ <a class="function" href="#Redshift.Generator.unnest_sql">unnest_sql</a> </li> <li> - <a class="function" href="#Redshift.Generator.with_properties">with_properties</a> - </li> - <li> <a class="function" href="#Redshift.Generator.cast_sql">cast_sql</a> </li> <li> <a class="function" href="#Redshift.Generator.datatype_sql">datatype_sql</a> </li> <li> + <a class="function" href="#Redshift.Generator.alterset_sql">alterset_sql</a> + </li> + <li> <a class="variable" href="#Redshift.Generator.SELECT_KINDS">SELECT_KINDS</a> </li> <li> @@ -395,265 +398,273 @@ </span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">COPY_PARAMS_ARE_WRAPPED</span> <span class="o">=</span> <span class="kc">False</span> </span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="n">HEX_FUNC</span> <span class="o">=</span> <span class="s2">"TO_HEX"</span> -</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> -</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> -</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="p">}</span> -</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">:</span> <span class="n">concat_ws_to_dpipe_sql</span><span class="p">,</span> -</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"APPROXIMATE COUNT(DISTINCT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</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-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> -</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="s2">"SYSDATE"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"transaction"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"GETDATE()"</span> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="p">),</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DISTKEY"</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-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> <span class="n">generatedasidentitycolumnconstraint_sql</span><span class="p">,</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LISTAGG"</span><span class="p">),</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</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-176"><a href="#L-176"><span class="linenos">176</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-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="p">[</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos">179</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-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> -</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="p">]</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="p">),</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StartsWith</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> || '%'"</span><span class="p">,</span> -</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> -</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"(TIMESTAMP 'epoch' + </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> * INTERVAL '1 SECOND')"</span><span class="p">,</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="p">}</span> -</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> -</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> -</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> -</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="c1"># Redshift supports ANY_VALUE(..)</span> -</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">)</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> -</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="c1"># Redshift supports LAST_DAY(..)</span> -</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> -</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="s2">"aes128"</span><span class="p">,</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="s2">"aes256"</span><span class="p">,</span> -</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="s2">"all"</span><span class="p">,</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="s2">"allowoverwrite"</span><span class="p">,</span> -</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="s2">"analyse"</span><span class="p">,</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="s2">"analyze"</span><span class="p">,</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="s2">"and"</span><span class="p">,</span> -</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="s2">"array"</span><span class="p">,</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="s2">"as"</span><span class="p">,</span> -</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="s2">"asc"</span><span class="p">,</span> -</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="s2">"authorization"</span><span class="p">,</span> -</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="s2">"az64"</span><span class="p">,</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="s2">"backup"</span><span class="p">,</span> -</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="s2">"between"</span><span class="p">,</span> -</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="s2">"binary"</span><span class="p">,</span> -</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="s2">"blanksasnull"</span><span class="p">,</span> -</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="s2">"both"</span><span class="p">,</span> -</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="s2">"bytedict"</span><span class="p">,</span> -</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="s2">"bzip2"</span><span class="p">,</span> -</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="s2">"case"</span><span class="p">,</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="s2">"cast"</span><span class="p">,</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="s2">"check"</span><span class="p">,</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="s2">"collate"</span><span class="p">,</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="s2">"column"</span><span class="p">,</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="s2">"constraint"</span><span class="p">,</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="s2">"create"</span><span class="p">,</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="s2">"credentials"</span><span class="p">,</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="s2">"cross"</span><span class="p">,</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="s2">"current_date"</span><span class="p">,</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="s2">"current_time"</span><span class="p">,</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="s2">"current_user"</span><span class="p">,</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="s2">"current_user_id"</span><span class="p">,</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="s2">"default"</span><span class="p">,</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="s2">"deflate"</span><span class="p">,</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="s2">"defrag"</span><span class="p">,</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="s2">"delta"</span><span class="p">,</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="s2">"delta32k"</span><span class="p">,</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"desc"</span><span class="p">,</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"disable"</span><span class="p">,</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="s2">"distinct"</span><span class="p">,</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="s2">"do"</span><span class="p">,</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="s2">"else"</span><span class="p">,</span> -</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="s2">"emptyasnull"</span><span class="p">,</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="s2">"enable"</span><span class="p">,</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="s2">"encode"</span><span class="p">,</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"encrypt "</span><span class="p">,</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="s2">"encryption"</span><span class="p">,</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="s2">"end"</span><span class="p">,</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="s2">"except"</span><span class="p">,</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="s2">"explicit"</span><span class="p">,</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="s2">"false"</span><span class="p">,</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="s2">"for"</span><span class="p">,</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="s2">"foreign"</span><span class="p">,</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="s2">"freeze"</span><span class="p">,</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="s2">"full"</span><span class="p">,</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="s2">"globaldict256"</span><span class="p">,</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="s2">"globaldict64k"</span><span class="p">,</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="s2">"grant"</span><span class="p">,</span> -</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="s2">"group"</span><span class="p">,</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="s2">"gzip"</span><span class="p">,</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="s2">"having"</span><span class="p">,</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="s2">"identity"</span><span class="p">,</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="s2">"ignore"</span><span class="p">,</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="s2">"ilike"</span><span class="p">,</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="s2">"in"</span><span class="p">,</span> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="s2">"initially"</span><span class="p">,</span> -</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="s2">"inner"</span><span class="p">,</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="s2">"intersect"</span><span class="p">,</span> -</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="s2">"interval"</span><span class="p">,</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="s2">"into"</span><span class="p">,</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="s2">"is"</span><span class="p">,</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="s2">"isnull"</span><span class="p">,</span> -</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="s2">"join"</span><span class="p">,</span> -</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="s2">"leading"</span><span class="p">,</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="s2">"left"</span><span class="p">,</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="s2">"like"</span><span class="p">,</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="s2">"limit"</span><span class="p">,</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="s2">"localtime"</span><span class="p">,</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="s2">"lun"</span><span class="p">,</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="s2">"luns"</span><span class="p">,</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="s2">"lzo"</span><span class="p">,</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="s2">"lzop"</span><span class="p">,</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="s2">"minus"</span><span class="p">,</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="s2">"mostly16"</span><span class="p">,</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="s2">"mostly32"</span><span class="p">,</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="s2">"mostly8"</span><span class="p">,</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="s2">"natural"</span><span class="p">,</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="s2">"new"</span><span class="p">,</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="s2">"not"</span><span class="p">,</span> -</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="s2">"notnull"</span><span class="p">,</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="s2">"null"</span><span class="p">,</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="s2">"nulls"</span><span class="p">,</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="s2">"off"</span><span class="p">,</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="s2">"offline"</span><span class="p">,</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="s2">"offset"</span><span class="p">,</span> -</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="s2">"oid"</span><span class="p">,</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="s2">"old"</span><span class="p">,</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="s2">"on"</span><span class="p">,</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="s2">"only"</span><span class="p">,</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="s2">"open"</span><span class="p">,</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="s2">"or"</span><span class="p">,</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="s2">"order"</span><span class="p">,</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="s2">"outer"</span><span class="p">,</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="s2">"overlaps"</span><span class="p">,</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="s2">"parallel"</span><span class="p">,</span> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="s2">"partition"</span><span class="p">,</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="s2">"percent"</span><span class="p">,</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="s2">"permissions"</span><span class="p">,</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="s2">"pivot"</span><span class="p">,</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="s2">"placing"</span><span class="p">,</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="s2">"primary"</span><span class="p">,</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="s2">"raw"</span><span class="p">,</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="s2">"readratio"</span><span class="p">,</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="s2">"recover"</span><span class="p">,</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="s2">"references"</span><span class="p">,</span> -</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="s2">"rejectlog"</span><span class="p">,</span> -</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="s2">"resort"</span><span class="p">,</span> -</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="s2">"respect"</span><span class="p">,</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="s2">"restore"</span><span class="p">,</span> -</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="s2">"right"</span><span class="p">,</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="s2">"select"</span><span class="p">,</span> -</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="s2">"session_user"</span><span class="p">,</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="s2">"similar"</span><span class="p">,</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="s2">"snapshot"</span><span class="p">,</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="s2">"some"</span><span class="p">,</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="s2">"sysdate"</span><span class="p">,</span> -</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="s2">"system"</span><span class="p">,</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="s2">"table"</span><span class="p">,</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="s2">"tag"</span><span class="p">,</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="s2">"tdes"</span><span class="p">,</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="s2">"text255"</span><span class="p">,</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="s2">"text32k"</span><span class="p">,</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="s2">"then"</span><span class="p">,</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="s2">"timestamp"</span><span class="p">,</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="s2">"top"</span><span class="p">,</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="s2">"trailing"</span><span class="p">,</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="s2">"true"</span><span class="p">,</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="s2">"truncatecolumns"</span><span class="p">,</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="s2">"type"</span><span class="p">,</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="s2">"union"</span><span class="p">,</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="s2">"unique"</span><span class="p">,</span> -</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="s2">"unnest"</span><span class="p">,</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="s2">"unpivot"</span><span class="p">,</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="s2">"user"</span><span class="p">,</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="s2">"using"</span><span class="p">,</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="s2">"verbose"</span><span class="p">,</span> -</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="s2">"wallet"</span><span class="p">,</span> -</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="s2">"when"</span><span class="p">,</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="s2">"with"</span><span class="p">,</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="s2">"without"</span><span class="p">,</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="p">}</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="n">num_args</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> -</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a> <span class="k">if</span> <span class="n">num_args</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported number of arguments in UNNEST: </span><span class="si">{</span><span class="n">num_args</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> -</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">arg</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">arg</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> -</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> -</span><span id="L-380"><a href="#L-380"><span class="linenos">380</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> -</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">JSON</span><span class="p">):</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> <span class="c1"># Redshift doesn't support a JSON type, so casting to it is treated as a noop</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="c1"># Redshift doesn't have `WITH` as part of their with_properties so we remove it</span> +</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="n">WITH_PROPERTIES_PREFIX</span> <span class="o">=</span> <span class="s2">" "</span> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> +</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="p">}</span> +</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> +</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">:</span> <span class="n">concat_ws_to_dpipe_sql</span><span class="p">,</span> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"APPROXIMATE COUNT(DISTINCT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</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-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="s2">"SYSDATE"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"transaction"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"GETDATE()"</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="p">),</span> +</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DISTKEY"</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-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> <span class="n">generatedasidentitycolumnconstraint_sql</span><span class="p">,</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LISTAGG"</span><span class="p">),</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</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-178"><a href="#L-178"><span class="linenos">178</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-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="p">[</span> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</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-181"><a href="#L-181"><span class="linenos">181</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-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="p">]</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="p">),</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StartsWith</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> || '%'"</span><span class="p">,</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"(TIMESTAMP 'epoch' + </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> * INTERVAL '1 SECOND')"</span><span class="p">,</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="p">}</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> +</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> +</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> +</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="c1"># Redshift supports ANY_VALUE(..)</span> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">)</span> +</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> +</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="c1"># Redshift supports LAST_DAY(..)</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> +</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> +</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="s2">"aes128"</span><span class="p">,</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="s2">"aes256"</span><span class="p">,</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="s2">"allowoverwrite"</span><span class="p">,</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="s2">"analyse"</span><span class="p">,</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="s2">"analyze"</span><span class="p">,</span> +</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="s2">"asc"</span><span class="p">,</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="s2">"authorization"</span><span class="p">,</span> +</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="s2">"az64"</span><span class="p">,</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="s2">"backup"</span><span class="p">,</span> +</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="s2">"between"</span><span class="p">,</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="s2">"binary"</span><span class="p">,</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="s2">"blanksasnull"</span><span class="p">,</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="s2">"both"</span><span class="p">,</span> +</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="s2">"bytedict"</span><span class="p">,</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="s2">"bzip2"</span><span class="p">,</span> +</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="s2">"check"</span><span class="p">,</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="s2">"column"</span><span class="p">,</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="s2">"constraint"</span><span class="p">,</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="s2">"create"</span><span class="p">,</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="s2">"credentials"</span><span class="p">,</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="s2">"cross"</span><span class="p">,</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="s2">"current_date"</span><span class="p">,</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="s2">"current_time"</span><span class="p">,</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="s2">"current_user"</span><span class="p">,</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="s2">"current_user_id"</span><span class="p">,</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="s2">"deflate"</span><span class="p">,</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="s2">"defrag"</span><span class="p">,</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"delta"</span><span class="p">,</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"delta32k"</span><span class="p">,</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="s2">"desc"</span><span class="p">,</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="s2">"disable"</span><span class="p">,</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="s2">"do"</span><span class="p">,</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="s2">"emptyasnull"</span><span class="p">,</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"enable"</span><span class="p">,</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="s2">"encode"</span><span class="p">,</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="s2">"encrypt "</span><span class="p">,</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="s2">"encryption"</span><span class="p">,</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="s2">"end"</span><span class="p">,</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="s2">"explicit"</span><span class="p">,</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="s2">"false"</span><span class="p">,</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="s2">"foreign"</span><span class="p">,</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="s2">"freeze"</span><span class="p">,</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="s2">"full"</span><span class="p">,</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="s2">"globaldict256"</span><span class="p">,</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="s2">"globaldict64k"</span><span class="p">,</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="s2">"grant"</span><span class="p">,</span> +</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="s2">"group"</span><span class="p">,</span> +</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="s2">"gzip"</span><span class="p">,</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="s2">"identity"</span><span class="p">,</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="s2">"ignore"</span><span class="p">,</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="s2">"ilike"</span><span class="p">,</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="s2">"in"</span><span class="p">,</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="s2">"initially"</span><span class="p">,</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="s2">"inner"</span><span class="p">,</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="s2">"interval"</span><span class="p">,</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="s2">"is"</span><span class="p">,</span> +</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="s2">"isnull"</span><span class="p">,</span> +</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="s2">"join"</span><span class="p">,</span> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="s2">"leading"</span><span class="p">,</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="s2">"left"</span><span class="p">,</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="s2">"like"</span><span class="p">,</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="s2">"localtime"</span><span class="p">,</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="s2">"lun"</span><span class="p">,</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="s2">"luns"</span><span class="p">,</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="s2">"lzo"</span><span class="p">,</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="s2">"lzop"</span><span class="p">,</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="s2">"minus"</span><span class="p">,</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="s2">"mostly16"</span><span class="p">,</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="s2">"mostly32"</span><span class="p">,</span> +</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="s2">"mostly8"</span><span class="p">,</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="s2">"natural"</span><span class="p">,</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="s2">"new"</span><span class="p">,</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="s2">"notnull"</span><span class="p">,</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="s2">"null"</span><span class="p">,</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="s2">"nulls"</span><span class="p">,</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="s2">"off"</span><span class="p">,</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="s2">"offline"</span><span class="p">,</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="s2">"offset"</span><span class="p">,</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="s2">"oid"</span><span class="p">,</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="s2">"old"</span><span class="p">,</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="s2">"only"</span><span class="p">,</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="s2">"open"</span><span class="p">,</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="s2">"outer"</span><span class="p">,</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="s2">"overlaps"</span><span class="p">,</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="s2">"parallel"</span><span class="p">,</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="s2">"partition"</span><span class="p">,</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="s2">"percent"</span><span class="p">,</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="s2">"permissions"</span><span class="p">,</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="s2">"pivot"</span><span class="p">,</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="s2">"placing"</span><span class="p">,</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="s2">"primary"</span><span class="p">,</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="s2">"raw"</span><span class="p">,</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="s2">"readratio"</span><span class="p">,</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="s2">"recover"</span><span class="p">,</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="s2">"references"</span><span class="p">,</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="s2">"rejectlog"</span><span class="p">,</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="s2">"resort"</span><span class="p">,</span> +</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="s2">"respect"</span><span class="p">,</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="s2">"restore"</span><span class="p">,</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="s2">"right"</span><span class="p">,</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="s2">"session_user"</span><span class="p">,</span> +</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="s2">"similar"</span><span class="p">,</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="s2">"snapshot"</span><span class="p">,</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="s2">"sysdate"</span><span class="p">,</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="s2">"system"</span><span class="p">,</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="s2">"table"</span><span class="p">,</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="s2">"tag"</span><span class="p">,</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="s2">"tdes"</span><span class="p">,</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="s2">"text255"</span><span class="p">,</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="s2">"text32k"</span><span class="p">,</span> +</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="s2">"timestamp"</span><span class="p">,</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="s2">"top"</span><span class="p">,</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="s2">"trailing"</span><span class="p">,</span> +</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="s2">"true"</span><span class="p">,</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="s2">"truncatecolumns"</span><span class="p">,</span> +</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="s2">"type"</span><span class="p">,</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="s2">"unique"</span><span class="p">,</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="s2">"unnest"</span><span class="p">,</span> +</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="s2">"unpivot"</span><span class="p">,</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="s2">"user"</span><span class="p">,</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="s2">"verbose"</span><span class="p">,</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="s2">"wallet"</span><span class="p">,</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> <span class="s2">"without"</span><span class="p">,</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="p">}</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> +</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a> <span class="n">num_args</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="k">if</span> <span class="n">num_args</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported number of arguments in UNNEST: </span><span class="si">{</span><span class="n">num_args</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> +</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> +</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">arg</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">arg</span> +</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> +</span><span id="L-380"><a href="#L-380"><span class="linenos">380</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">JSON</span><span class="p">):</span> +</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="c1"># Redshift doesn't support a JSON type, so casting to it is treated as a noop</span> +</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> +</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> </span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a> -</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> -</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> -</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a><span class="sd"> """</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> -</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> -</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> -</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> -</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> +</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> +</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> +</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a><span class="sd"> """</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> +</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> +</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a> +</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> -</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="k">def</span> <span class="nf">alterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> <span class="n">exprs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="n">exprs</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TABLE PROPERTIES (</span><span class="si">{</span><span class="n">exprs</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">exprs</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="n">location</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"location"</span><span class="p">)</span> +</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> <span class="n">location</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LOCATION </span><span class="si">{</span><span class="n">location</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">location</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"file_format"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FILE FORMAT </span><span class="si">{</span><span class="n">file_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">file_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> +</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">exprs</span><span class="si">}{</span><span class="n">location</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -779,265 +790,273 @@ </span><span id="Redshift-143"><a href="#Redshift-143"><span class="linenos">143</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="Redshift-144"><a href="#Redshift-144"><span class="linenos">144</span></a> <span class="n">COPY_PARAMS_ARE_WRAPPED</span> <span class="o">=</span> <span class="kc">False</span> </span><span id="Redshift-145"><a href="#Redshift-145"><span class="linenos">145</span></a> <span class="n">HEX_FUNC</span> <span class="o">=</span> <span class="s2">"TO_HEX"</span> -</span><span id="Redshift-146"><a href="#Redshift-146"><span class="linenos">146</span></a> -</span><span id="Redshift-147"><a href="#Redshift-147"><span class="linenos">147</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift-148"><a href="#Redshift-148"><span class="linenos">148</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="Redshift-149"><a href="#Redshift-149"><span class="linenos">149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift-150"><a href="#Redshift-150"><span class="linenos">150</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="Redshift-151"><a href="#Redshift-151"><span class="linenos">151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> -</span><span id="Redshift-152"><a href="#Redshift-152"><span class="linenos">152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Redshift-153"><a href="#Redshift-153"><span class="linenos">153</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift-154"><a href="#Redshift-154"><span class="linenos">154</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift-155"><a href="#Redshift-155"><span class="linenos">155</span></a> <span class="p">}</span> -</span><span id="Redshift-156"><a href="#Redshift-156"><span class="linenos">156</span></a> -</span><span id="Redshift-157"><a href="#Redshift-157"><span class="linenos">157</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift-158"><a href="#Redshift-158"><span class="linenos">158</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="Redshift-159"><a href="#Redshift-159"><span class="linenos">159</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="Redshift-160"><a href="#Redshift-160"><span class="linenos">160</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">:</span> <span class="n">concat_ws_to_dpipe_sql</span><span class="p">,</span> -</span><span id="Redshift-161"><a href="#Redshift-161"><span class="linenos">161</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Redshift-162"><a href="#Redshift-162"><span class="linenos">162</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"APPROXIMATE COUNT(DISTINCT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</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="Redshift-163"><a href="#Redshift-163"><span class="linenos">163</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> -</span><span id="Redshift-164"><a href="#Redshift-164"><span class="linenos">164</span></a> <span class="s2">"SYSDATE"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"transaction"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"GETDATE()"</span> -</span><span id="Redshift-165"><a href="#Redshift-165"><span class="linenos">165</span></a> <span class="p">),</span> -</span><span id="Redshift-166"><a href="#Redshift-166"><span class="linenos">166</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> -</span><span id="Redshift-167"><a href="#Redshift-167"><span class="linenos">167</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> -</span><span id="Redshift-168"><a href="#Redshift-168"><span class="linenos">168</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DISTKEY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> -</span><span id="Redshift-169"><a href="#Redshift-169"><span class="linenos">169</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Redshift-170"><a href="#Redshift-170"><span class="linenos">170</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> -</span><span id="Redshift-171"><a href="#Redshift-171"><span class="linenos">171</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> <span class="n">generatedasidentitycolumnconstraint_sql</span><span class="p">,</span> -</span><span id="Redshift-172"><a href="#Redshift-172"><span class="linenos">172</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> -</span><span id="Redshift-173"><a href="#Redshift-173"><span class="linenos">173</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> -</span><span id="Redshift-174"><a href="#Redshift-174"><span class="linenos">174</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LISTAGG"</span><span class="p">),</span> -</span><span id="Redshift-175"><a href="#Redshift-175"><span class="linenos">175</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> -</span><span id="Redshift-176"><a href="#Redshift-176"><span class="linenos">176</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="Redshift-177"><a href="#Redshift-177"><span class="linenos">177</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="Redshift-178"><a href="#Redshift-178"><span class="linenos">178</span></a> <span class="p">[</span> -</span><span id="Redshift-179"><a href="#Redshift-179"><span class="linenos">179</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="Redshift-180"><a href="#Redshift-180"><span class="linenos">180</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="Redshift-181"><a href="#Redshift-181"><span class="linenos">181</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> -</span><span id="Redshift-182"><a href="#Redshift-182"><span class="linenos">182</span></a> <span class="p">]</span> -</span><span id="Redshift-183"><a href="#Redshift-183"><span class="linenos">183</span></a> <span class="p">),</span> -</span><span id="Redshift-184"><a href="#Redshift-184"><span class="linenos">184</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Redshift-185"><a href="#Redshift-185"><span class="linenos">185</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Redshift-186"><a href="#Redshift-186"><span class="linenos">186</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StartsWith</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Redshift-187"><a href="#Redshift-187"><span class="linenos">187</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> || '%'"</span><span class="p">,</span> -</span><span id="Redshift-188"><a href="#Redshift-188"><span class="linenos">188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> -</span><span id="Redshift-189"><a href="#Redshift-189"><span class="linenos">189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> -</span><span id="Redshift-190"><a href="#Redshift-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> -</span><span id="Redshift-191"><a href="#Redshift-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Redshift-192"><a href="#Redshift-192"><span class="linenos">192</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"(TIMESTAMP 'epoch' + </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> * INTERVAL '1 SECOND')"</span><span class="p">,</span> -</span><span id="Redshift-193"><a href="#Redshift-193"><span class="linenos">193</span></a> <span class="p">}</span> -</span><span id="Redshift-194"><a href="#Redshift-194"><span class="linenos">194</span></a> -</span><span id="Redshift-195"><a href="#Redshift-195"><span class="linenos">195</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> -</span><span id="Redshift-196"><a href="#Redshift-196"><span class="linenos">196</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> -</span><span id="Redshift-197"><a href="#Redshift-197"><span class="linenos">197</span></a> -</span><span id="Redshift-198"><a href="#Redshift-198"><span class="linenos">198</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> -</span><span id="Redshift-199"><a href="#Redshift-199"><span class="linenos">199</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> -</span><span id="Redshift-200"><a href="#Redshift-200"><span class="linenos">200</span></a> -</span><span id="Redshift-201"><a href="#Redshift-201"><span class="linenos">201</span></a> <span class="c1"># Redshift supports ANY_VALUE(..)</span> -</span><span id="Redshift-202"><a href="#Redshift-202"><span class="linenos">202</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">)</span> -</span><span id="Redshift-203"><a href="#Redshift-203"><span class="linenos">203</span></a> -</span><span id="Redshift-204"><a href="#Redshift-204"><span class="linenos">204</span></a> <span class="c1"># Redshift supports LAST_DAY(..)</span> -</span><span id="Redshift-205"><a href="#Redshift-205"><span class="linenos">205</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> -</span><span id="Redshift-206"><a href="#Redshift-206"><span class="linenos">206</span></a> -</span><span id="Redshift-207"><a href="#Redshift-207"><span class="linenos">207</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift-208"><a href="#Redshift-208"><span class="linenos">208</span></a> <span class="s2">"aes128"</span><span class="p">,</span> -</span><span id="Redshift-209"><a href="#Redshift-209"><span class="linenos">209</span></a> <span class="s2">"aes256"</span><span class="p">,</span> -</span><span id="Redshift-210"><a href="#Redshift-210"><span class="linenos">210</span></a> <span class="s2">"all"</span><span class="p">,</span> -</span><span id="Redshift-211"><a href="#Redshift-211"><span class="linenos">211</span></a> <span class="s2">"allowoverwrite"</span><span class="p">,</span> -</span><span id="Redshift-212"><a href="#Redshift-212"><span class="linenos">212</span></a> <span class="s2">"analyse"</span><span class="p">,</span> -</span><span id="Redshift-213"><a href="#Redshift-213"><span class="linenos">213</span></a> <span class="s2">"analyze"</span><span class="p">,</span> -</span><span id="Redshift-214"><a href="#Redshift-214"><span class="linenos">214</span></a> <span class="s2">"and"</span><span class="p">,</span> -</span><span id="Redshift-215"><a href="#Redshift-215"><span class="linenos">215</span></a> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="Redshift-216"><a href="#Redshift-216"><span class="linenos">216</span></a> <span class="s2">"array"</span><span class="p">,</span> -</span><span id="Redshift-217"><a href="#Redshift-217"><span class="linenos">217</span></a> <span class="s2">"as"</span><span class="p">,</span> -</span><span id="Redshift-218"><a href="#Redshift-218"><span class="linenos">218</span></a> <span class="s2">"asc"</span><span class="p">,</span> -</span><span id="Redshift-219"><a href="#Redshift-219"><span class="linenos">219</span></a> <span class="s2">"authorization"</span><span class="p">,</span> -</span><span id="Redshift-220"><a href="#Redshift-220"><span class="linenos">220</span></a> <span class="s2">"az64"</span><span class="p">,</span> -</span><span id="Redshift-221"><a href="#Redshift-221"><span class="linenos">221</span></a> <span class="s2">"backup"</span><span class="p">,</span> -</span><span id="Redshift-222"><a href="#Redshift-222"><span class="linenos">222</span></a> <span class="s2">"between"</span><span class="p">,</span> -</span><span id="Redshift-223"><a href="#Redshift-223"><span class="linenos">223</span></a> <span class="s2">"binary"</span><span class="p">,</span> -</span><span id="Redshift-224"><a href="#Redshift-224"><span class="linenos">224</span></a> <span class="s2">"blanksasnull"</span><span class="p">,</span> -</span><span id="Redshift-225"><a href="#Redshift-225"><span class="linenos">225</span></a> <span class="s2">"both"</span><span class="p">,</span> -</span><span id="Redshift-226"><a href="#Redshift-226"><span class="linenos">226</span></a> <span class="s2">"bytedict"</span><span class="p">,</span> -</span><span id="Redshift-227"><a href="#Redshift-227"><span class="linenos">227</span></a> <span class="s2">"bzip2"</span><span class="p">,</span> -</span><span id="Redshift-228"><a href="#Redshift-228"><span class="linenos">228</span></a> <span class="s2">"case"</span><span class="p">,</span> -</span><span id="Redshift-229"><a href="#Redshift-229"><span class="linenos">229</span></a> <span class="s2">"cast"</span><span class="p">,</span> -</span><span id="Redshift-230"><a href="#Redshift-230"><span class="linenos">230</span></a> <span class="s2">"check"</span><span class="p">,</span> -</span><span id="Redshift-231"><a href="#Redshift-231"><span class="linenos">231</span></a> <span class="s2">"collate"</span><span class="p">,</span> -</span><span id="Redshift-232"><a href="#Redshift-232"><span class="linenos">232</span></a> <span class="s2">"column"</span><span class="p">,</span> -</span><span id="Redshift-233"><a href="#Redshift-233"><span class="linenos">233</span></a> <span class="s2">"constraint"</span><span class="p">,</span> -</span><span id="Redshift-234"><a href="#Redshift-234"><span class="linenos">234</span></a> <span class="s2">"create"</span><span class="p">,</span> -</span><span id="Redshift-235"><a href="#Redshift-235"><span class="linenos">235</span></a> <span class="s2">"credentials"</span><span class="p">,</span> -</span><span id="Redshift-236"><a href="#Redshift-236"><span class="linenos">236</span></a> <span class="s2">"cross"</span><span class="p">,</span> -</span><span id="Redshift-237"><a href="#Redshift-237"><span class="linenos">237</span></a> <span class="s2">"current_date"</span><span class="p">,</span> -</span><span id="Redshift-238"><a href="#Redshift-238"><span class="linenos">238</span></a> <span class="s2">"current_time"</span><span class="p">,</span> -</span><span id="Redshift-239"><a href="#Redshift-239"><span class="linenos">239</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> -</span><span id="Redshift-240"><a href="#Redshift-240"><span class="linenos">240</span></a> <span class="s2">"current_user"</span><span class="p">,</span> -</span><span id="Redshift-241"><a href="#Redshift-241"><span class="linenos">241</span></a> <span class="s2">"current_user_id"</span><span class="p">,</span> -</span><span id="Redshift-242"><a href="#Redshift-242"><span class="linenos">242</span></a> <span class="s2">"default"</span><span class="p">,</span> -</span><span id="Redshift-243"><a href="#Redshift-243"><span class="linenos">243</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> -</span><span id="Redshift-244"><a href="#Redshift-244"><span class="linenos">244</span></a> <span class="s2">"deflate"</span><span class="p">,</span> -</span><span id="Redshift-245"><a href="#Redshift-245"><span class="linenos">245</span></a> <span class="s2">"defrag"</span><span class="p">,</span> -</span><span id="Redshift-246"><a href="#Redshift-246"><span class="linenos">246</span></a> <span class="s2">"delta"</span><span class="p">,</span> -</span><span id="Redshift-247"><a href="#Redshift-247"><span class="linenos">247</span></a> <span class="s2">"delta32k"</span><span class="p">,</span> -</span><span id="Redshift-248"><a href="#Redshift-248"><span class="linenos">248</span></a> <span class="s2">"desc"</span><span class="p">,</span> -</span><span id="Redshift-249"><a href="#Redshift-249"><span class="linenos">249</span></a> <span class="s2">"disable"</span><span class="p">,</span> -</span><span id="Redshift-250"><a href="#Redshift-250"><span class="linenos">250</span></a> <span class="s2">"distinct"</span><span class="p">,</span> -</span><span id="Redshift-251"><a href="#Redshift-251"><span class="linenos">251</span></a> <span class="s2">"do"</span><span class="p">,</span> -</span><span id="Redshift-252"><a href="#Redshift-252"><span class="linenos">252</span></a> <span class="s2">"else"</span><span class="p">,</span> -</span><span id="Redshift-253"><a href="#Redshift-253"><span class="linenos">253</span></a> <span class="s2">"emptyasnull"</span><span class="p">,</span> -</span><span id="Redshift-254"><a href="#Redshift-254"><span class="linenos">254</span></a> <span class="s2">"enable"</span><span class="p">,</span> -</span><span id="Redshift-255"><a href="#Redshift-255"><span class="linenos">255</span></a> <span class="s2">"encode"</span><span class="p">,</span> -</span><span id="Redshift-256"><a href="#Redshift-256"><span class="linenos">256</span></a> <span class="s2">"encrypt "</span><span class="p">,</span> -</span><span id="Redshift-257"><a href="#Redshift-257"><span class="linenos">257</span></a> <span class="s2">"encryption"</span><span class="p">,</span> -</span><span id="Redshift-258"><a href="#Redshift-258"><span class="linenos">258</span></a> <span class="s2">"end"</span><span class="p">,</span> -</span><span id="Redshift-259"><a href="#Redshift-259"><span class="linenos">259</span></a> <span class="s2">"except"</span><span class="p">,</span> -</span><span id="Redshift-260"><a href="#Redshift-260"><span class="linenos">260</span></a> <span class="s2">"explicit"</span><span class="p">,</span> -</span><span id="Redshift-261"><a href="#Redshift-261"><span class="linenos">261</span></a> <span class="s2">"false"</span><span class="p">,</span> -</span><span id="Redshift-262"><a href="#Redshift-262"><span class="linenos">262</span></a> <span class="s2">"for"</span><span class="p">,</span> -</span><span id="Redshift-263"><a href="#Redshift-263"><span class="linenos">263</span></a> <span class="s2">"foreign"</span><span class="p">,</span> -</span><span id="Redshift-264"><a href="#Redshift-264"><span class="linenos">264</span></a> <span class="s2">"freeze"</span><span class="p">,</span> -</span><span id="Redshift-265"><a href="#Redshift-265"><span class="linenos">265</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="Redshift-266"><a href="#Redshift-266"><span class="linenos">266</span></a> <span class="s2">"full"</span><span class="p">,</span> -</span><span id="Redshift-267"><a href="#Redshift-267"><span class="linenos">267</span></a> <span class="s2">"globaldict256"</span><span class="p">,</span> -</span><span id="Redshift-268"><a href="#Redshift-268"><span class="linenos">268</span></a> <span class="s2">"globaldict64k"</span><span class="p">,</span> -</span><span id="Redshift-269"><a href="#Redshift-269"><span class="linenos">269</span></a> <span class="s2">"grant"</span><span class="p">,</span> -</span><span id="Redshift-270"><a href="#Redshift-270"><span class="linenos">270</span></a> <span class="s2">"group"</span><span class="p">,</span> -</span><span id="Redshift-271"><a href="#Redshift-271"><span class="linenos">271</span></a> <span class="s2">"gzip"</span><span class="p">,</span> -</span><span id="Redshift-272"><a href="#Redshift-272"><span class="linenos">272</span></a> <span class="s2">"having"</span><span class="p">,</span> -</span><span id="Redshift-273"><a href="#Redshift-273"><span class="linenos">273</span></a> <span class="s2">"identity"</span><span class="p">,</span> -</span><span id="Redshift-274"><a href="#Redshift-274"><span class="linenos">274</span></a> <span class="s2">"ignore"</span><span class="p">,</span> -</span><span id="Redshift-275"><a href="#Redshift-275"><span class="linenos">275</span></a> <span class="s2">"ilike"</span><span class="p">,</span> -</span><span id="Redshift-276"><a href="#Redshift-276"><span class="linenos">276</span></a> <span class="s2">"in"</span><span class="p">,</span> -</span><span id="Redshift-277"><a href="#Redshift-277"><span class="linenos">277</span></a> <span class="s2">"initially"</span><span class="p">,</span> -</span><span id="Redshift-278"><a href="#Redshift-278"><span class="linenos">278</span></a> <span class="s2">"inner"</span><span class="p">,</span> -</span><span id="Redshift-279"><a href="#Redshift-279"><span class="linenos">279</span></a> <span class="s2">"intersect"</span><span class="p">,</span> -</span><span id="Redshift-280"><a href="#Redshift-280"><span class="linenos">280</span></a> <span class="s2">"interval"</span><span class="p">,</span> -</span><span id="Redshift-281"><a href="#Redshift-281"><span class="linenos">281</span></a> <span class="s2">"into"</span><span class="p">,</span> -</span><span id="Redshift-282"><a href="#Redshift-282"><span class="linenos">282</span></a> <span class="s2">"is"</span><span class="p">,</span> -</span><span id="Redshift-283"><a href="#Redshift-283"><span class="linenos">283</span></a> <span class="s2">"isnull"</span><span class="p">,</span> -</span><span id="Redshift-284"><a href="#Redshift-284"><span class="linenos">284</span></a> <span class="s2">"join"</span><span class="p">,</span> -</span><span id="Redshift-285"><a href="#Redshift-285"><span class="linenos">285</span></a> <span class="s2">"leading"</span><span class="p">,</span> -</span><span id="Redshift-286"><a href="#Redshift-286"><span class="linenos">286</span></a> <span class="s2">"left"</span><span class="p">,</span> -</span><span id="Redshift-287"><a href="#Redshift-287"><span class="linenos">287</span></a> <span class="s2">"like"</span><span class="p">,</span> -</span><span id="Redshift-288"><a href="#Redshift-288"><span class="linenos">288</span></a> <span class="s2">"limit"</span><span class="p">,</span> -</span><span id="Redshift-289"><a href="#Redshift-289"><span class="linenos">289</span></a> <span class="s2">"localtime"</span><span class="p">,</span> -</span><span id="Redshift-290"><a href="#Redshift-290"><span class="linenos">290</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> -</span><span id="Redshift-291"><a href="#Redshift-291"><span class="linenos">291</span></a> <span class="s2">"lun"</span><span class="p">,</span> -</span><span id="Redshift-292"><a href="#Redshift-292"><span class="linenos">292</span></a> <span class="s2">"luns"</span><span class="p">,</span> -</span><span id="Redshift-293"><a href="#Redshift-293"><span class="linenos">293</span></a> <span class="s2">"lzo"</span><span class="p">,</span> -</span><span id="Redshift-294"><a href="#Redshift-294"><span class="linenos">294</span></a> <span class="s2">"lzop"</span><span class="p">,</span> -</span><span id="Redshift-295"><a href="#Redshift-295"><span class="linenos">295</span></a> <span class="s2">"minus"</span><span class="p">,</span> -</span><span id="Redshift-296"><a href="#Redshift-296"><span class="linenos">296</span></a> <span class="s2">"mostly16"</span><span class="p">,</span> -</span><span id="Redshift-297"><a href="#Redshift-297"><span class="linenos">297</span></a> <span class="s2">"mostly32"</span><span class="p">,</span> -</span><span id="Redshift-298"><a href="#Redshift-298"><span class="linenos">298</span></a> <span class="s2">"mostly8"</span><span class="p">,</span> -</span><span id="Redshift-299"><a href="#Redshift-299"><span class="linenos">299</span></a> <span class="s2">"natural"</span><span class="p">,</span> -</span><span id="Redshift-300"><a href="#Redshift-300"><span class="linenos">300</span></a> <span class="s2">"new"</span><span class="p">,</span> -</span><span id="Redshift-301"><a href="#Redshift-301"><span class="linenos">301</span></a> <span class="s2">"not"</span><span class="p">,</span> -</span><span id="Redshift-302"><a href="#Redshift-302"><span class="linenos">302</span></a> <span class="s2">"notnull"</span><span class="p">,</span> -</span><span id="Redshift-303"><a href="#Redshift-303"><span class="linenos">303</span></a> <span class="s2">"null"</span><span class="p">,</span> -</span><span id="Redshift-304"><a href="#Redshift-304"><span class="linenos">304</span></a> <span class="s2">"nulls"</span><span class="p">,</span> -</span><span id="Redshift-305"><a href="#Redshift-305"><span class="linenos">305</span></a> <span class="s2">"off"</span><span class="p">,</span> -</span><span id="Redshift-306"><a href="#Redshift-306"><span class="linenos">306</span></a> <span class="s2">"offline"</span><span class="p">,</span> -</span><span id="Redshift-307"><a href="#Redshift-307"><span class="linenos">307</span></a> <span class="s2">"offset"</span><span class="p">,</span> -</span><span id="Redshift-308"><a href="#Redshift-308"><span class="linenos">308</span></a> <span class="s2">"oid"</span><span class="p">,</span> -</span><span id="Redshift-309"><a href="#Redshift-309"><span class="linenos">309</span></a> <span class="s2">"old"</span><span class="p">,</span> -</span><span id="Redshift-310"><a href="#Redshift-310"><span class="linenos">310</span></a> <span class="s2">"on"</span><span class="p">,</span> -</span><span id="Redshift-311"><a href="#Redshift-311"><span class="linenos">311</span></a> <span class="s2">"only"</span><span class="p">,</span> -</span><span id="Redshift-312"><a href="#Redshift-312"><span class="linenos">312</span></a> <span class="s2">"open"</span><span class="p">,</span> -</span><span id="Redshift-313"><a href="#Redshift-313"><span class="linenos">313</span></a> <span class="s2">"or"</span><span class="p">,</span> -</span><span id="Redshift-314"><a href="#Redshift-314"><span class="linenos">314</span></a> <span class="s2">"order"</span><span class="p">,</span> -</span><span id="Redshift-315"><a href="#Redshift-315"><span class="linenos">315</span></a> <span class="s2">"outer"</span><span class="p">,</span> -</span><span id="Redshift-316"><a href="#Redshift-316"><span class="linenos">316</span></a> <span class="s2">"overlaps"</span><span class="p">,</span> -</span><span id="Redshift-317"><a href="#Redshift-317"><span class="linenos">317</span></a> <span class="s2">"parallel"</span><span class="p">,</span> -</span><span id="Redshift-318"><a href="#Redshift-318"><span class="linenos">318</span></a> <span class="s2">"partition"</span><span class="p">,</span> -</span><span id="Redshift-319"><a href="#Redshift-319"><span class="linenos">319</span></a> <span class="s2">"percent"</span><span class="p">,</span> -</span><span id="Redshift-320"><a href="#Redshift-320"><span class="linenos">320</span></a> <span class="s2">"permissions"</span><span class="p">,</span> -</span><span id="Redshift-321"><a href="#Redshift-321"><span class="linenos">321</span></a> <span class="s2">"pivot"</span><span class="p">,</span> -</span><span id="Redshift-322"><a href="#Redshift-322"><span class="linenos">322</span></a> <span class="s2">"placing"</span><span class="p">,</span> -</span><span id="Redshift-323"><a href="#Redshift-323"><span class="linenos">323</span></a> <span class="s2">"primary"</span><span class="p">,</span> -</span><span id="Redshift-324"><a href="#Redshift-324"><span class="linenos">324</span></a> <span class="s2">"raw"</span><span class="p">,</span> -</span><span id="Redshift-325"><a href="#Redshift-325"><span class="linenos">325</span></a> <span class="s2">"readratio"</span><span class="p">,</span> -</span><span id="Redshift-326"><a href="#Redshift-326"><span class="linenos">326</span></a> <span class="s2">"recover"</span><span class="p">,</span> -</span><span id="Redshift-327"><a href="#Redshift-327"><span class="linenos">327</span></a> <span class="s2">"references"</span><span class="p">,</span> -</span><span id="Redshift-328"><a href="#Redshift-328"><span class="linenos">328</span></a> <span class="s2">"rejectlog"</span><span class="p">,</span> -</span><span id="Redshift-329"><a href="#Redshift-329"><span class="linenos">329</span></a> <span class="s2">"resort"</span><span class="p">,</span> -</span><span id="Redshift-330"><a href="#Redshift-330"><span class="linenos">330</span></a> <span class="s2">"respect"</span><span class="p">,</span> -</span><span id="Redshift-331"><a href="#Redshift-331"><span class="linenos">331</span></a> <span class="s2">"restore"</span><span class="p">,</span> -</span><span id="Redshift-332"><a href="#Redshift-332"><span class="linenos">332</span></a> <span class="s2">"right"</span><span class="p">,</span> -</span><span id="Redshift-333"><a href="#Redshift-333"><span class="linenos">333</span></a> <span class="s2">"select"</span><span class="p">,</span> -</span><span id="Redshift-334"><a href="#Redshift-334"><span class="linenos">334</span></a> <span class="s2">"session_user"</span><span class="p">,</span> -</span><span id="Redshift-335"><a href="#Redshift-335"><span class="linenos">335</span></a> <span class="s2">"similar"</span><span class="p">,</span> -</span><span id="Redshift-336"><a href="#Redshift-336"><span class="linenos">336</span></a> <span class="s2">"snapshot"</span><span class="p">,</span> -</span><span id="Redshift-337"><a href="#Redshift-337"><span class="linenos">337</span></a> <span class="s2">"some"</span><span class="p">,</span> -</span><span id="Redshift-338"><a href="#Redshift-338"><span class="linenos">338</span></a> <span class="s2">"sysdate"</span><span class="p">,</span> -</span><span id="Redshift-339"><a href="#Redshift-339"><span class="linenos">339</span></a> <span class="s2">"system"</span><span class="p">,</span> -</span><span id="Redshift-340"><a href="#Redshift-340"><span class="linenos">340</span></a> <span class="s2">"table"</span><span class="p">,</span> -</span><span id="Redshift-341"><a href="#Redshift-341"><span class="linenos">341</span></a> <span class="s2">"tag"</span><span class="p">,</span> -</span><span id="Redshift-342"><a href="#Redshift-342"><span class="linenos">342</span></a> <span class="s2">"tdes"</span><span class="p">,</span> -</span><span id="Redshift-343"><a href="#Redshift-343"><span class="linenos">343</span></a> <span class="s2">"text255"</span><span class="p">,</span> -</span><span id="Redshift-344"><a href="#Redshift-344"><span class="linenos">344</span></a> <span class="s2">"text32k"</span><span class="p">,</span> -</span><span id="Redshift-345"><a href="#Redshift-345"><span class="linenos">345</span></a> <span class="s2">"then"</span><span class="p">,</span> -</span><span id="Redshift-346"><a href="#Redshift-346"><span class="linenos">346</span></a> <span class="s2">"timestamp"</span><span class="p">,</span> -</span><span id="Redshift-347"><a href="#Redshift-347"><span class="linenos">347</span></a> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="Redshift-348"><a href="#Redshift-348"><span class="linenos">348</span></a> <span class="s2">"top"</span><span class="p">,</span> -</span><span id="Redshift-349"><a href="#Redshift-349"><span class="linenos">349</span></a> <span class="s2">"trailing"</span><span class="p">,</span> -</span><span id="Redshift-350"><a href="#Redshift-350"><span class="linenos">350</span></a> <span class="s2">"true"</span><span class="p">,</span> -</span><span id="Redshift-351"><a href="#Redshift-351"><span class="linenos">351</span></a> <span class="s2">"truncatecolumns"</span><span class="p">,</span> -</span><span id="Redshift-352"><a href="#Redshift-352"><span class="linenos">352</span></a> <span class="s2">"type"</span><span class="p">,</span> -</span><span id="Redshift-353"><a href="#Redshift-353"><span class="linenos">353</span></a> <span class="s2">"union"</span><span class="p">,</span> -</span><span id="Redshift-354"><a href="#Redshift-354"><span class="linenos">354</span></a> <span class="s2">"unique"</span><span class="p">,</span> -</span><span id="Redshift-355"><a href="#Redshift-355"><span class="linenos">355</span></a> <span class="s2">"unnest"</span><span class="p">,</span> -</span><span id="Redshift-356"><a href="#Redshift-356"><span class="linenos">356</span></a> <span class="s2">"unpivot"</span><span class="p">,</span> -</span><span id="Redshift-357"><a href="#Redshift-357"><span class="linenos">357</span></a> <span class="s2">"user"</span><span class="p">,</span> -</span><span id="Redshift-358"><a href="#Redshift-358"><span class="linenos">358</span></a> <span class="s2">"using"</span><span class="p">,</span> -</span><span id="Redshift-359"><a href="#Redshift-359"><span class="linenos">359</span></a> <span class="s2">"verbose"</span><span class="p">,</span> -</span><span id="Redshift-360"><a href="#Redshift-360"><span class="linenos">360</span></a> <span class="s2">"wallet"</span><span class="p">,</span> -</span><span id="Redshift-361"><a href="#Redshift-361"><span class="linenos">361</span></a> <span class="s2">"when"</span><span class="p">,</span> -</span><span id="Redshift-362"><a href="#Redshift-362"><span class="linenos">362</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="Redshift-363"><a href="#Redshift-363"><span class="linenos">363</span></a> <span class="s2">"with"</span><span class="p">,</span> -</span><span id="Redshift-364"><a href="#Redshift-364"><span class="linenos">364</span></a> <span class="s2">"without"</span><span class="p">,</span> -</span><span id="Redshift-365"><a href="#Redshift-365"><span class="linenos">365</span></a> <span class="p">}</span> -</span><span id="Redshift-366"><a href="#Redshift-366"><span class="linenos">366</span></a> -</span><span id="Redshift-367"><a href="#Redshift-367"><span class="linenos">367</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift-368"><a href="#Redshift-368"><span class="linenos">368</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Redshift-369"><a href="#Redshift-369"><span class="linenos">369</span></a> <span class="n">num_args</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> -</span><span id="Redshift-370"><a href="#Redshift-370"><span class="linenos">370</span></a> -</span><span id="Redshift-371"><a href="#Redshift-371"><span class="linenos">371</span></a> <span class="k">if</span> <span class="n">num_args</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Redshift-372"><a href="#Redshift-372"><span class="linenos">372</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported number of arguments in UNNEST: </span><span class="si">{</span><span class="n">num_args</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Redshift-373"><a href="#Redshift-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Redshift-374"><a href="#Redshift-374"><span class="linenos">374</span></a> -</span><span id="Redshift-375"><a href="#Redshift-375"><span class="linenos">375</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> -</span><span id="Redshift-376"><a href="#Redshift-376"><span class="linenos">376</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Redshift-377"><a href="#Redshift-377"><span class="linenos">377</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">arg</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">arg</span> -</span><span id="Redshift-378"><a href="#Redshift-378"><span class="linenos">378</span></a> -</span><span id="Redshift-379"><a href="#Redshift-379"><span class="linenos">379</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift-380"><a href="#Redshift-380"><span class="linenos">380</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> -</span><span id="Redshift-381"><a href="#Redshift-381"><span class="linenos">381</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Redshift-382"><a href="#Redshift-382"><span class="linenos">382</span></a> -</span><span id="Redshift-383"><a href="#Redshift-383"><span class="linenos">383</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift-384"><a href="#Redshift-384"><span class="linenos">384</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">JSON</span><span class="p">):</span> -</span><span id="Redshift-385"><a href="#Redshift-385"><span class="linenos">385</span></a> <span class="c1"># Redshift doesn't support a JSON type, so casting to it is treated as a noop</span> -</span><span id="Redshift-386"><a href="#Redshift-386"><span class="linenos">386</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Redshift-146"><a href="#Redshift-146"><span class="linenos">146</span></a> <span class="c1"># Redshift doesn't have `WITH` as part of their with_properties so we remove it</span> +</span><span id="Redshift-147"><a href="#Redshift-147"><span class="linenos">147</span></a> <span class="n">WITH_PROPERTIES_PREFIX</span> <span class="o">=</span> <span class="s2">" "</span> +</span><span id="Redshift-148"><a href="#Redshift-148"><span class="linenos">148</span></a> +</span><span id="Redshift-149"><a href="#Redshift-149"><span class="linenos">149</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift-150"><a href="#Redshift-150"><span class="linenos">150</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="Redshift-151"><a href="#Redshift-151"><span class="linenos">151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift-152"><a href="#Redshift-152"><span class="linenos">152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="Redshift-153"><a href="#Redshift-153"><span class="linenos">153</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> +</span><span id="Redshift-154"><a href="#Redshift-154"><span class="linenos">154</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Redshift-155"><a href="#Redshift-155"><span class="linenos">155</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift-156"><a href="#Redshift-156"><span class="linenos">156</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift-157"><a href="#Redshift-157"><span class="linenos">157</span></a> <span class="p">}</span> +</span><span id="Redshift-158"><a href="#Redshift-158"><span class="linenos">158</span></a> +</span><span id="Redshift-159"><a href="#Redshift-159"><span class="linenos">159</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift-160"><a href="#Redshift-160"><span class="linenos">160</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="Redshift-161"><a href="#Redshift-161"><span class="linenos">161</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="Redshift-162"><a href="#Redshift-162"><span class="linenos">162</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">:</span> <span class="n">concat_ws_to_dpipe_sql</span><span class="p">,</span> +</span><span id="Redshift-163"><a href="#Redshift-163"><span class="linenos">163</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Redshift-164"><a href="#Redshift-164"><span class="linenos">164</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"APPROXIMATE COUNT(DISTINCT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</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="Redshift-165"><a href="#Redshift-165"><span class="linenos">165</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> +</span><span id="Redshift-166"><a href="#Redshift-166"><span class="linenos">166</span></a> <span class="s2">"SYSDATE"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"transaction"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"GETDATE()"</span> +</span><span id="Redshift-167"><a href="#Redshift-167"><span class="linenos">167</span></a> <span class="p">),</span> +</span><span id="Redshift-168"><a href="#Redshift-168"><span class="linenos">168</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> +</span><span id="Redshift-169"><a href="#Redshift-169"><span class="linenos">169</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> +</span><span id="Redshift-170"><a href="#Redshift-170"><span class="linenos">170</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DISTKEY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> +</span><span id="Redshift-171"><a href="#Redshift-171"><span class="linenos">171</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Redshift-172"><a href="#Redshift-172"><span class="linenos">172</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> +</span><span id="Redshift-173"><a href="#Redshift-173"><span class="linenos">173</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> <span class="n">generatedasidentitycolumnconstraint_sql</span><span class="p">,</span> +</span><span id="Redshift-174"><a href="#Redshift-174"><span class="linenos">174</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> +</span><span id="Redshift-175"><a href="#Redshift-175"><span class="linenos">175</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> +</span><span id="Redshift-176"><a href="#Redshift-176"><span class="linenos">176</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LISTAGG"</span><span class="p">),</span> +</span><span id="Redshift-177"><a href="#Redshift-177"><span class="linenos">177</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> +</span><span id="Redshift-178"><a href="#Redshift-178"><span class="linenos">178</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="Redshift-179"><a href="#Redshift-179"><span class="linenos">179</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="Redshift-180"><a href="#Redshift-180"><span class="linenos">180</span></a> <span class="p">[</span> +</span><span id="Redshift-181"><a href="#Redshift-181"><span class="linenos">181</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="Redshift-182"><a href="#Redshift-182"><span class="linenos">182</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="Redshift-183"><a href="#Redshift-183"><span class="linenos">183</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> +</span><span id="Redshift-184"><a href="#Redshift-184"><span class="linenos">184</span></a> <span class="p">]</span> +</span><span id="Redshift-185"><a href="#Redshift-185"><span class="linenos">185</span></a> <span class="p">),</span> +</span><span id="Redshift-186"><a href="#Redshift-186"><span class="linenos">186</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Redshift-187"><a href="#Redshift-187"><span class="linenos">187</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Redshift-188"><a href="#Redshift-188"><span class="linenos">188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StartsWith</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Redshift-189"><a href="#Redshift-189"><span class="linenos">189</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> || '%'"</span><span class="p">,</span> +</span><span id="Redshift-190"><a href="#Redshift-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> +</span><span id="Redshift-191"><a href="#Redshift-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> +</span><span id="Redshift-192"><a href="#Redshift-192"><span class="linenos">192</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> +</span><span id="Redshift-193"><a href="#Redshift-193"><span class="linenos">193</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Redshift-194"><a href="#Redshift-194"><span class="linenos">194</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"(TIMESTAMP 'epoch' + </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> * INTERVAL '1 SECOND')"</span><span class="p">,</span> +</span><span id="Redshift-195"><a href="#Redshift-195"><span class="linenos">195</span></a> <span class="p">}</span> +</span><span id="Redshift-196"><a href="#Redshift-196"><span class="linenos">196</span></a> +</span><span id="Redshift-197"><a href="#Redshift-197"><span class="linenos">197</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> +</span><span id="Redshift-198"><a href="#Redshift-198"><span class="linenos">198</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> +</span><span id="Redshift-199"><a href="#Redshift-199"><span class="linenos">199</span></a> +</span><span id="Redshift-200"><a href="#Redshift-200"><span class="linenos">200</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> +</span><span id="Redshift-201"><a href="#Redshift-201"><span class="linenos">201</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> +</span><span id="Redshift-202"><a href="#Redshift-202"><span class="linenos">202</span></a> +</span><span id="Redshift-203"><a href="#Redshift-203"><span class="linenos">203</span></a> <span class="c1"># Redshift supports ANY_VALUE(..)</span> +</span><span id="Redshift-204"><a href="#Redshift-204"><span class="linenos">204</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">)</span> +</span><span id="Redshift-205"><a href="#Redshift-205"><span class="linenos">205</span></a> +</span><span id="Redshift-206"><a href="#Redshift-206"><span class="linenos">206</span></a> <span class="c1"># Redshift supports LAST_DAY(..)</span> +</span><span id="Redshift-207"><a href="#Redshift-207"><span class="linenos">207</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> +</span><span id="Redshift-208"><a href="#Redshift-208"><span class="linenos">208</span></a> +</span><span id="Redshift-209"><a href="#Redshift-209"><span class="linenos">209</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift-210"><a href="#Redshift-210"><span class="linenos">210</span></a> <span class="s2">"aes128"</span><span class="p">,</span> +</span><span id="Redshift-211"><a href="#Redshift-211"><span class="linenos">211</span></a> <span class="s2">"aes256"</span><span class="p">,</span> +</span><span id="Redshift-212"><a href="#Redshift-212"><span class="linenos">212</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="Redshift-213"><a href="#Redshift-213"><span class="linenos">213</span></a> <span class="s2">"allowoverwrite"</span><span class="p">,</span> +</span><span id="Redshift-214"><a href="#Redshift-214"><span class="linenos">214</span></a> <span class="s2">"analyse"</span><span class="p">,</span> +</span><span id="Redshift-215"><a href="#Redshift-215"><span class="linenos">215</span></a> <span class="s2">"analyze"</span><span class="p">,</span> +</span><span id="Redshift-216"><a href="#Redshift-216"><span class="linenos">216</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="Redshift-217"><a href="#Redshift-217"><span class="linenos">217</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="Redshift-218"><a href="#Redshift-218"><span class="linenos">218</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="Redshift-219"><a href="#Redshift-219"><span class="linenos">219</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="Redshift-220"><a href="#Redshift-220"><span class="linenos">220</span></a> <span class="s2">"asc"</span><span class="p">,</span> +</span><span id="Redshift-221"><a href="#Redshift-221"><span class="linenos">221</span></a> <span class="s2">"authorization"</span><span class="p">,</span> +</span><span id="Redshift-222"><a href="#Redshift-222"><span class="linenos">222</span></a> <span class="s2">"az64"</span><span class="p">,</span> +</span><span id="Redshift-223"><a href="#Redshift-223"><span class="linenos">223</span></a> <span class="s2">"backup"</span><span class="p">,</span> +</span><span id="Redshift-224"><a href="#Redshift-224"><span class="linenos">224</span></a> <span class="s2">"between"</span><span class="p">,</span> +</span><span id="Redshift-225"><a href="#Redshift-225"><span class="linenos">225</span></a> <span class="s2">"binary"</span><span class="p">,</span> +</span><span id="Redshift-226"><a href="#Redshift-226"><span class="linenos">226</span></a> <span class="s2">"blanksasnull"</span><span class="p">,</span> +</span><span id="Redshift-227"><a href="#Redshift-227"><span class="linenos">227</span></a> <span class="s2">"both"</span><span class="p">,</span> +</span><span id="Redshift-228"><a href="#Redshift-228"><span class="linenos">228</span></a> <span class="s2">"bytedict"</span><span class="p">,</span> +</span><span id="Redshift-229"><a href="#Redshift-229"><span class="linenos">229</span></a> <span class="s2">"bzip2"</span><span class="p">,</span> +</span><span id="Redshift-230"><a href="#Redshift-230"><span class="linenos">230</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="Redshift-231"><a href="#Redshift-231"><span class="linenos">231</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="Redshift-232"><a href="#Redshift-232"><span class="linenos">232</span></a> <span class="s2">"check"</span><span class="p">,</span> +</span><span id="Redshift-233"><a href="#Redshift-233"><span class="linenos">233</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="Redshift-234"><a href="#Redshift-234"><span class="linenos">234</span></a> <span class="s2">"column"</span><span class="p">,</span> +</span><span id="Redshift-235"><a href="#Redshift-235"><span class="linenos">235</span></a> <span class="s2">"constraint"</span><span class="p">,</span> +</span><span id="Redshift-236"><a href="#Redshift-236"><span class="linenos">236</span></a> <span class="s2">"create"</span><span class="p">,</span> +</span><span id="Redshift-237"><a href="#Redshift-237"><span class="linenos">237</span></a> <span class="s2">"credentials"</span><span class="p">,</span> +</span><span id="Redshift-238"><a href="#Redshift-238"><span class="linenos">238</span></a> <span class="s2">"cross"</span><span class="p">,</span> +</span><span id="Redshift-239"><a href="#Redshift-239"><span class="linenos">239</span></a> <span class="s2">"current_date"</span><span class="p">,</span> +</span><span id="Redshift-240"><a href="#Redshift-240"><span class="linenos">240</span></a> <span class="s2">"current_time"</span><span class="p">,</span> +</span><span id="Redshift-241"><a href="#Redshift-241"><span class="linenos">241</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> +</span><span id="Redshift-242"><a href="#Redshift-242"><span class="linenos">242</span></a> <span class="s2">"current_user"</span><span class="p">,</span> +</span><span id="Redshift-243"><a href="#Redshift-243"><span class="linenos">243</span></a> <span class="s2">"current_user_id"</span><span class="p">,</span> +</span><span id="Redshift-244"><a href="#Redshift-244"><span class="linenos">244</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="Redshift-245"><a href="#Redshift-245"><span class="linenos">245</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> +</span><span id="Redshift-246"><a href="#Redshift-246"><span class="linenos">246</span></a> <span class="s2">"deflate"</span><span class="p">,</span> +</span><span id="Redshift-247"><a href="#Redshift-247"><span class="linenos">247</span></a> <span class="s2">"defrag"</span><span class="p">,</span> +</span><span id="Redshift-248"><a href="#Redshift-248"><span class="linenos">248</span></a> <span class="s2">"delta"</span><span class="p">,</span> +</span><span id="Redshift-249"><a href="#Redshift-249"><span class="linenos">249</span></a> <span class="s2">"delta32k"</span><span class="p">,</span> +</span><span id="Redshift-250"><a href="#Redshift-250"><span class="linenos">250</span></a> <span class="s2">"desc"</span><span class="p">,</span> +</span><span id="Redshift-251"><a href="#Redshift-251"><span class="linenos">251</span></a> <span class="s2">"disable"</span><span class="p">,</span> +</span><span id="Redshift-252"><a href="#Redshift-252"><span class="linenos">252</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="Redshift-253"><a href="#Redshift-253"><span class="linenos">253</span></a> <span class="s2">"do"</span><span class="p">,</span> +</span><span id="Redshift-254"><a href="#Redshift-254"><span class="linenos">254</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="Redshift-255"><a href="#Redshift-255"><span class="linenos">255</span></a> <span class="s2">"emptyasnull"</span><span class="p">,</span> +</span><span id="Redshift-256"><a href="#Redshift-256"><span class="linenos">256</span></a> <span class="s2">"enable"</span><span class="p">,</span> +</span><span id="Redshift-257"><a href="#Redshift-257"><span class="linenos">257</span></a> <span class="s2">"encode"</span><span class="p">,</span> +</span><span id="Redshift-258"><a href="#Redshift-258"><span class="linenos">258</span></a> <span class="s2">"encrypt "</span><span class="p">,</span> +</span><span id="Redshift-259"><a href="#Redshift-259"><span class="linenos">259</span></a> <span class="s2">"encryption"</span><span class="p">,</span> +</span><span id="Redshift-260"><a href="#Redshift-260"><span class="linenos">260</span></a> <span class="s2">"end"</span><span class="p">,</span> +</span><span id="Redshift-261"><a href="#Redshift-261"><span class="linenos">261</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="Redshift-262"><a href="#Redshift-262"><span class="linenos">262</span></a> <span class="s2">"explicit"</span><span class="p">,</span> +</span><span id="Redshift-263"><a href="#Redshift-263"><span class="linenos">263</span></a> <span class="s2">"false"</span><span class="p">,</span> +</span><span id="Redshift-264"><a href="#Redshift-264"><span class="linenos">264</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="Redshift-265"><a href="#Redshift-265"><span class="linenos">265</span></a> <span class="s2">"foreign"</span><span class="p">,</span> +</span><span id="Redshift-266"><a href="#Redshift-266"><span class="linenos">266</span></a> <span class="s2">"freeze"</span><span class="p">,</span> +</span><span id="Redshift-267"><a href="#Redshift-267"><span class="linenos">267</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="Redshift-268"><a href="#Redshift-268"><span class="linenos">268</span></a> <span class="s2">"full"</span><span class="p">,</span> +</span><span id="Redshift-269"><a href="#Redshift-269"><span class="linenos">269</span></a> <span class="s2">"globaldict256"</span><span class="p">,</span> +</span><span id="Redshift-270"><a href="#Redshift-270"><span class="linenos">270</span></a> <span class="s2">"globaldict64k"</span><span class="p">,</span> +</span><span id="Redshift-271"><a href="#Redshift-271"><span class="linenos">271</span></a> <span class="s2">"grant"</span><span class="p">,</span> +</span><span id="Redshift-272"><a href="#Redshift-272"><span class="linenos">272</span></a> <span class="s2">"group"</span><span class="p">,</span> +</span><span id="Redshift-273"><a href="#Redshift-273"><span class="linenos">273</span></a> <span class="s2">"gzip"</span><span class="p">,</span> +</span><span id="Redshift-274"><a href="#Redshift-274"><span class="linenos">274</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="Redshift-275"><a href="#Redshift-275"><span class="linenos">275</span></a> <span class="s2">"identity"</span><span class="p">,</span> +</span><span id="Redshift-276"><a href="#Redshift-276"><span class="linenos">276</span></a> <span class="s2">"ignore"</span><span class="p">,</span> +</span><span id="Redshift-277"><a href="#Redshift-277"><span class="linenos">277</span></a> <span class="s2">"ilike"</span><span class="p">,</span> +</span><span id="Redshift-278"><a href="#Redshift-278"><span class="linenos">278</span></a> <span class="s2">"in"</span><span class="p">,</span> +</span><span id="Redshift-279"><a href="#Redshift-279"><span class="linenos">279</span></a> <span class="s2">"initially"</span><span class="p">,</span> +</span><span id="Redshift-280"><a href="#Redshift-280"><span class="linenos">280</span></a> <span class="s2">"inner"</span><span class="p">,</span> +</span><span id="Redshift-281"><a href="#Redshift-281"><span class="linenos">281</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="Redshift-282"><a href="#Redshift-282"><span class="linenos">282</span></a> <span class="s2">"interval"</span><span class="p">,</span> +</span><span id="Redshift-283"><a href="#Redshift-283"><span class="linenos">283</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="Redshift-284"><a href="#Redshift-284"><span class="linenos">284</span></a> <span class="s2">"is"</span><span class="p">,</span> +</span><span id="Redshift-285"><a href="#Redshift-285"><span class="linenos">285</span></a> <span class="s2">"isnull"</span><span class="p">,</span> +</span><span id="Redshift-286"><a href="#Redshift-286"><span class="linenos">286</span></a> <span class="s2">"join"</span><span class="p">,</span> +</span><span id="Redshift-287"><a href="#Redshift-287"><span class="linenos">287</span></a> <span class="s2">"leading"</span><span class="p">,</span> +</span><span id="Redshift-288"><a href="#Redshift-288"><span class="linenos">288</span></a> <span class="s2">"left"</span><span class="p">,</span> +</span><span id="Redshift-289"><a href="#Redshift-289"><span class="linenos">289</span></a> <span class="s2">"like"</span><span class="p">,</span> +</span><span id="Redshift-290"><a href="#Redshift-290"><span class="linenos">290</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="Redshift-291"><a href="#Redshift-291"><span class="linenos">291</span></a> <span class="s2">"localtime"</span><span class="p">,</span> +</span><span id="Redshift-292"><a href="#Redshift-292"><span class="linenos">292</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> +</span><span id="Redshift-293"><a href="#Redshift-293"><span class="linenos">293</span></a> <span class="s2">"lun"</span><span class="p">,</span> +</span><span id="Redshift-294"><a href="#Redshift-294"><span class="linenos">294</span></a> <span class="s2">"luns"</span><span class="p">,</span> +</span><span id="Redshift-295"><a href="#Redshift-295"><span class="linenos">295</span></a> <span class="s2">"lzo"</span><span class="p">,</span> +</span><span id="Redshift-296"><a href="#Redshift-296"><span class="linenos">296</span></a> <span class="s2">"lzop"</span><span class="p">,</span> +</span><span id="Redshift-297"><a href="#Redshift-297"><span class="linenos">297</span></a> <span class="s2">"minus"</span><span class="p">,</span> +</span><span id="Redshift-298"><a href="#Redshift-298"><span class="linenos">298</span></a> <span class="s2">"mostly16"</span><span class="p">,</span> +</span><span id="Redshift-299"><a href="#Redshift-299"><span class="linenos">299</span></a> <span class="s2">"mostly32"</span><span class="p">,</span> +</span><span id="Redshift-300"><a href="#Redshift-300"><span class="linenos">300</span></a> <span class="s2">"mostly8"</span><span class="p">,</span> +</span><span id="Redshift-301"><a href="#Redshift-301"><span class="linenos">301</span></a> <span class="s2">"natural"</span><span class="p">,</span> +</span><span id="Redshift-302"><a href="#Redshift-302"><span class="linenos">302</span></a> <span class="s2">"new"</span><span class="p">,</span> +</span><span id="Redshift-303"><a href="#Redshift-303"><span class="linenos">303</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="Redshift-304"><a href="#Redshift-304"><span class="linenos">304</span></a> <span class="s2">"notnull"</span><span class="p">,</span> +</span><span id="Redshift-305"><a href="#Redshift-305"><span class="linenos">305</span></a> <span class="s2">"null"</span><span class="p">,</span> +</span><span id="Redshift-306"><a href="#Redshift-306"><span class="linenos">306</span></a> <span class="s2">"nulls"</span><span class="p">,</span> +</span><span id="Redshift-307"><a href="#Redshift-307"><span class="linenos">307</span></a> <span class="s2">"off"</span><span class="p">,</span> +</span><span id="Redshift-308"><a href="#Redshift-308"><span class="linenos">308</span></a> <span class="s2">"offline"</span><span class="p">,</span> +</span><span id="Redshift-309"><a href="#Redshift-309"><span class="linenos">309</span></a> <span class="s2">"offset"</span><span class="p">,</span> +</span><span id="Redshift-310"><a href="#Redshift-310"><span class="linenos">310</span></a> <span class="s2">"oid"</span><span class="p">,</span> +</span><span id="Redshift-311"><a href="#Redshift-311"><span class="linenos">311</span></a> <span class="s2">"old"</span><span class="p">,</span> +</span><span id="Redshift-312"><a href="#Redshift-312"><span class="linenos">312</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="Redshift-313"><a href="#Redshift-313"><span class="linenos">313</span></a> <span class="s2">"only"</span><span class="p">,</span> +</span><span id="Redshift-314"><a href="#Redshift-314"><span class="linenos">314</span></a> <span class="s2">"open"</span><span class="p">,</span> +</span><span id="Redshift-315"><a href="#Redshift-315"><span class="linenos">315</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="Redshift-316"><a href="#Redshift-316"><span class="linenos">316</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="Redshift-317"><a href="#Redshift-317"><span class="linenos">317</span></a> <span class="s2">"outer"</span><span class="p">,</span> +</span><span id="Redshift-318"><a href="#Redshift-318"><span class="linenos">318</span></a> <span class="s2">"overlaps"</span><span class="p">,</span> +</span><span id="Redshift-319"><a href="#Redshift-319"><span class="linenos">319</span></a> <span class="s2">"parallel"</span><span class="p">,</span> +</span><span id="Redshift-320"><a href="#Redshift-320"><span class="linenos">320</span></a> <span class="s2">"partition"</span><span class="p">,</span> +</span><span id="Redshift-321"><a href="#Redshift-321"><span class="linenos">321</span></a> <span class="s2">"percent"</span><span class="p">,</span> +</span><span id="Redshift-322"><a href="#Redshift-322"><span class="linenos">322</span></a> <span class="s2">"permissions"</span><span class="p">,</span> +</span><span id="Redshift-323"><a href="#Redshift-323"><span class="linenos">323</span></a> <span class="s2">"pivot"</span><span class="p">,</span> +</span><span id="Redshift-324"><a href="#Redshift-324"><span class="linenos">324</span></a> <span class="s2">"placing"</span><span class="p">,</span> +</span><span id="Redshift-325"><a href="#Redshift-325"><span class="linenos">325</span></a> <span class="s2">"primary"</span><span class="p">,</span> +</span><span id="Redshift-326"><a href="#Redshift-326"><span class="linenos">326</span></a> <span class="s2">"raw"</span><span class="p">,</span> +</span><span id="Redshift-327"><a href="#Redshift-327"><span class="linenos">327</span></a> <span class="s2">"readratio"</span><span class="p">,</span> +</span><span id="Redshift-328"><a href="#Redshift-328"><span class="linenos">328</span></a> <span class="s2">"recover"</span><span class="p">,</span> +</span><span id="Redshift-329"><a href="#Redshift-329"><span class="linenos">329</span></a> <span class="s2">"references"</span><span class="p">,</span> +</span><span id="Redshift-330"><a href="#Redshift-330"><span class="linenos">330</span></a> <span class="s2">"rejectlog"</span><span class="p">,</span> +</span><span id="Redshift-331"><a href="#Redshift-331"><span class="linenos">331</span></a> <span class="s2">"resort"</span><span class="p">,</span> +</span><span id="Redshift-332"><a href="#Redshift-332"><span class="linenos">332</span></a> <span class="s2">"respect"</span><span class="p">,</span> +</span><span id="Redshift-333"><a href="#Redshift-333"><span class="linenos">333</span></a> <span class="s2">"restore"</span><span class="p">,</span> +</span><span id="Redshift-334"><a href="#Redshift-334"><span class="linenos">334</span></a> <span class="s2">"right"</span><span class="p">,</span> +</span><span id="Redshift-335"><a href="#Redshift-335"><span class="linenos">335</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="Redshift-336"><a href="#Redshift-336"><span class="linenos">336</span></a> <span class="s2">"session_user"</span><span class="p">,</span> +</span><span id="Redshift-337"><a href="#Redshift-337"><span class="linenos">337</span></a> <span class="s2">"similar"</span><span class="p">,</span> +</span><span id="Redshift-338"><a href="#Redshift-338"><span class="linenos">338</span></a> <span class="s2">"snapshot"</span><span class="p">,</span> +</span><span id="Redshift-339"><a href="#Redshift-339"><span class="linenos">339</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="Redshift-340"><a href="#Redshift-340"><span class="linenos">340</span></a> <span class="s2">"sysdate"</span><span class="p">,</span> +</span><span id="Redshift-341"><a href="#Redshift-341"><span class="linenos">341</span></a> <span class="s2">"system"</span><span class="p">,</span> +</span><span id="Redshift-342"><a href="#Redshift-342"><span class="linenos">342</span></a> <span class="s2">"table"</span><span class="p">,</span> +</span><span id="Redshift-343"><a href="#Redshift-343"><span class="linenos">343</span></a> <span class="s2">"tag"</span><span class="p">,</span> +</span><span id="Redshift-344"><a href="#Redshift-344"><span class="linenos">344</span></a> <span class="s2">"tdes"</span><span class="p">,</span> +</span><span id="Redshift-345"><a href="#Redshift-345"><span class="linenos">345</span></a> <span class="s2">"text255"</span><span class="p">,</span> +</span><span id="Redshift-346"><a href="#Redshift-346"><span class="linenos">346</span></a> <span class="s2">"text32k"</span><span class="p">,</span> +</span><span id="Redshift-347"><a href="#Redshift-347"><span class="linenos">347</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="Redshift-348"><a href="#Redshift-348"><span class="linenos">348</span></a> <span class="s2">"timestamp"</span><span class="p">,</span> +</span><span id="Redshift-349"><a href="#Redshift-349"><span class="linenos">349</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="Redshift-350"><a href="#Redshift-350"><span class="linenos">350</span></a> <span class="s2">"top"</span><span class="p">,</span> +</span><span id="Redshift-351"><a href="#Redshift-351"><span class="linenos">351</span></a> <span class="s2">"trailing"</span><span class="p">,</span> +</span><span id="Redshift-352"><a href="#Redshift-352"><span class="linenos">352</span></a> <span class="s2">"true"</span><span class="p">,</span> +</span><span id="Redshift-353"><a href="#Redshift-353"><span class="linenos">353</span></a> <span class="s2">"truncatecolumns"</span><span class="p">,</span> +</span><span id="Redshift-354"><a href="#Redshift-354"><span class="linenos">354</span></a> <span class="s2">"type"</span><span class="p">,</span> +</span><span id="Redshift-355"><a href="#Redshift-355"><span class="linenos">355</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="Redshift-356"><a href="#Redshift-356"><span class="linenos">356</span></a> <span class="s2">"unique"</span><span class="p">,</span> +</span><span id="Redshift-357"><a href="#Redshift-357"><span class="linenos">357</span></a> <span class="s2">"unnest"</span><span class="p">,</span> +</span><span id="Redshift-358"><a href="#Redshift-358"><span class="linenos">358</span></a> <span class="s2">"unpivot"</span><span class="p">,</span> +</span><span id="Redshift-359"><a href="#Redshift-359"><span class="linenos">359</span></a> <span class="s2">"user"</span><span class="p">,</span> +</span><span id="Redshift-360"><a href="#Redshift-360"><span class="linenos">360</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="Redshift-361"><a href="#Redshift-361"><span class="linenos">361</span></a> <span class="s2">"verbose"</span><span class="p">,</span> +</span><span id="Redshift-362"><a href="#Redshift-362"><span class="linenos">362</span></a> <span class="s2">"wallet"</span><span class="p">,</span> +</span><span id="Redshift-363"><a href="#Redshift-363"><span class="linenos">363</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="Redshift-364"><a href="#Redshift-364"><span class="linenos">364</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="Redshift-365"><a href="#Redshift-365"><span class="linenos">365</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="Redshift-366"><a href="#Redshift-366"><span class="linenos">366</span></a> <span class="s2">"without"</span><span class="p">,</span> +</span><span id="Redshift-367"><a href="#Redshift-367"><span class="linenos">367</span></a> <span class="p">}</span> +</span><span id="Redshift-368"><a href="#Redshift-368"><span class="linenos">368</span></a> +</span><span id="Redshift-369"><a href="#Redshift-369"><span class="linenos">369</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift-370"><a href="#Redshift-370"><span class="linenos">370</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Redshift-371"><a href="#Redshift-371"><span class="linenos">371</span></a> <span class="n">num_args</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> +</span><span id="Redshift-372"><a href="#Redshift-372"><span class="linenos">372</span></a> +</span><span id="Redshift-373"><a href="#Redshift-373"><span class="linenos">373</span></a> <span class="k">if</span> <span class="n">num_args</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Redshift-374"><a href="#Redshift-374"><span class="linenos">374</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported number of arguments in UNNEST: </span><span class="si">{</span><span class="n">num_args</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Redshift-375"><a href="#Redshift-375"><span class="linenos">375</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Redshift-376"><a href="#Redshift-376"><span class="linenos">376</span></a> +</span><span id="Redshift-377"><a href="#Redshift-377"><span class="linenos">377</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> +</span><span id="Redshift-378"><a href="#Redshift-378"><span class="linenos">378</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Redshift-379"><a href="#Redshift-379"><span class="linenos">379</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">arg</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">arg</span> +</span><span id="Redshift-380"><a href="#Redshift-380"><span class="linenos">380</span></a> +</span><span id="Redshift-381"><a href="#Redshift-381"><span class="linenos">381</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift-382"><a href="#Redshift-382"><span class="linenos">382</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">JSON</span><span class="p">):</span> +</span><span id="Redshift-383"><a href="#Redshift-383"><span class="linenos">383</span></a> <span class="c1"># Redshift doesn't support a JSON type, so casting to it is treated as a noop</span> +</span><span id="Redshift-384"><a href="#Redshift-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Redshift-385"><a href="#Redshift-385"><span class="linenos">385</span></a> +</span><span id="Redshift-386"><a href="#Redshift-386"><span class="linenos">386</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> </span><span id="Redshift-387"><a href="#Redshift-387"><span class="linenos">387</span></a> -</span><span id="Redshift-388"><a href="#Redshift-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> -</span><span id="Redshift-389"><a href="#Redshift-389"><span class="linenos">389</span></a> -</span><span id="Redshift-390"><a href="#Redshift-390"><span class="linenos">390</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift-391"><a href="#Redshift-391"><span class="linenos">391</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Redshift-392"><a href="#Redshift-392"><span class="linenos">392</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> -</span><span id="Redshift-393"><a href="#Redshift-393"><span class="linenos">393</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> -</span><span id="Redshift-394"><a href="#Redshift-394"><span class="linenos">394</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> -</span><span id="Redshift-395"><a href="#Redshift-395"><span class="linenos">395</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> -</span><span id="Redshift-396"><a href="#Redshift-396"><span class="linenos">396</span></a><span class="sd"> """</span> -</span><span id="Redshift-397"><a href="#Redshift-397"><span class="linenos">397</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> -</span><span id="Redshift-398"><a href="#Redshift-398"><span class="linenos">398</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span> -</span><span id="Redshift-399"><a href="#Redshift-399"><span class="linenos">399</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> -</span><span id="Redshift-400"><a href="#Redshift-400"><span class="linenos">400</span></a> -</span><span id="Redshift-401"><a href="#Redshift-401"><span class="linenos">401</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> -</span><span id="Redshift-402"><a href="#Redshift-402"><span class="linenos">402</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift-388"><a href="#Redshift-388"><span class="linenos">388</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift-389"><a href="#Redshift-389"><span class="linenos">389</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Redshift-390"><a href="#Redshift-390"><span class="linenos">390</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> +</span><span id="Redshift-391"><a href="#Redshift-391"><span class="linenos">391</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> +</span><span id="Redshift-392"><a href="#Redshift-392"><span class="linenos">392</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> +</span><span id="Redshift-393"><a href="#Redshift-393"><span class="linenos">393</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> +</span><span id="Redshift-394"><a href="#Redshift-394"><span class="linenos">394</span></a><span class="sd"> """</span> +</span><span id="Redshift-395"><a href="#Redshift-395"><span class="linenos">395</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> +</span><span id="Redshift-396"><a href="#Redshift-396"><span class="linenos">396</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span> +</span><span id="Redshift-397"><a href="#Redshift-397"><span class="linenos">397</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> +</span><span id="Redshift-398"><a href="#Redshift-398"><span class="linenos">398</span></a> +</span><span id="Redshift-399"><a href="#Redshift-399"><span class="linenos">399</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> +</span><span id="Redshift-400"><a href="#Redshift-400"><span class="linenos">400</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift-401"><a href="#Redshift-401"><span class="linenos">401</span></a> +</span><span id="Redshift-402"><a href="#Redshift-402"><span class="linenos">402</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="Redshift-403"><a href="#Redshift-403"><span class="linenos">403</span></a> -</span><span id="Redshift-404"><a href="#Redshift-404"><span class="linenos">404</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Redshift-404"><a href="#Redshift-404"><span class="linenos">404</span></a> <span class="k">def</span> <span class="nf">alterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift-405"><a href="#Redshift-405"><span class="linenos">405</span></a> <span class="n">exprs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Redshift-406"><a href="#Redshift-406"><span class="linenos">406</span></a> <span class="n">exprs</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TABLE PROPERTIES (</span><span class="si">{</span><span class="n">exprs</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">exprs</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Redshift-407"><a href="#Redshift-407"><span class="linenos">407</span></a> <span class="n">location</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"location"</span><span class="p">)</span> +</span><span id="Redshift-408"><a href="#Redshift-408"><span class="linenos">408</span></a> <span class="n">location</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LOCATION </span><span class="si">{</span><span class="n">location</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">location</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Redshift-409"><a href="#Redshift-409"><span class="linenos">409</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"file_format"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Redshift-410"><a href="#Redshift-410"><span class="linenos">410</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FILE FORMAT </span><span class="si">{</span><span class="n">file_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">file_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Redshift-411"><a href="#Redshift-411"><span class="linenos">411</span></a> +</span><span id="Redshift-412"><a href="#Redshift-412"><span class="linenos">412</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">exprs</span><span class="si">}{</span><span class="n">location</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1696,6 +1715,7 @@ Default: 3</li> <dd id="Redshift.Parser.MODIFIERS_ATTACHED_TO_UNION" class="variable"><a href="../parser.html#Parser.MODIFIERS_ATTACHED_TO_UNION">MODIFIERS_ATTACHED_TO_UNION</a></dd> <dd id="Redshift.Parser.UNION_MODIFIERS" class="variable"><a href="../parser.html#Parser.UNION_MODIFIERS">UNION_MODIFIERS</a></dd> <dd id="Redshift.Parser.NO_PAREN_IF_COMMANDS" class="variable"><a href="../parser.html#Parser.NO_PAREN_IF_COMMANDS">NO_PAREN_IF_COMMANDS</a></dd> + <dd id="Redshift.Parser.COLON_IS_JSON_EXTRACT" class="variable"><a href="../parser.html#Parser.COLON_IS_JSON_EXTRACT">COLON_IS_JSON_EXTRACT</a></dd> <dd id="Redshift.Parser.VALUES_FOLLOWED_BY_PAREN" class="variable"><a href="../parser.html#Parser.VALUES_FOLLOWED_BY_PAREN">VALUES_FOLLOWED_BY_PAREN</a></dd> <dd id="Redshift.Parser.INTERVAL_SPANS" class="variable"><a href="../parser.html#Parser.INTERVAL_SPANS">INTERVAL_SPANS</a></dd> <dd id="Redshift.Parser.SUPPORTS_PARTITION_SELECTION" class="variable"><a href="../parser.html#Parser.SUPPORTS_PARTITION_SELECTION">SUPPORTS_PARTITION_SELECTION</a></dd> @@ -1881,265 +1901,273 @@ Default: 3</li> </span><span id="Redshift.Generator-143"><a href="#Redshift.Generator-143"><span class="linenos">143</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="Redshift.Generator-144"><a href="#Redshift.Generator-144"><span class="linenos">144</span></a> <span class="n">COPY_PARAMS_ARE_WRAPPED</span> <span class="o">=</span> <span class="kc">False</span> </span><span id="Redshift.Generator-145"><a href="#Redshift.Generator-145"><span class="linenos">145</span></a> <span class="n">HEX_FUNC</span> <span class="o">=</span> <span class="s2">"TO_HEX"</span> -</span><span id="Redshift.Generator-146"><a href="#Redshift.Generator-146"><span class="linenos">146</span></a> -</span><span id="Redshift.Generator-147"><a href="#Redshift.Generator-147"><span class="linenos">147</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift.Generator-148"><a href="#Redshift.Generator-148"><span class="linenos">148</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="Redshift.Generator-149"><a href="#Redshift.Generator-149"><span class="linenos">149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift.Generator-150"><a href="#Redshift.Generator-150"><span class="linenos">150</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="Redshift.Generator-151"><a href="#Redshift.Generator-151"><span class="linenos">151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> -</span><span id="Redshift.Generator-152"><a href="#Redshift.Generator-152"><span class="linenos">152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Redshift.Generator-153"><a href="#Redshift.Generator-153"><span class="linenos">153</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift.Generator-154"><a href="#Redshift.Generator-154"><span class="linenos">154</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift.Generator-155"><a href="#Redshift.Generator-155"><span class="linenos">155</span></a> <span class="p">}</span> -</span><span id="Redshift.Generator-156"><a href="#Redshift.Generator-156"><span class="linenos">156</span></a> -</span><span id="Redshift.Generator-157"><a href="#Redshift.Generator-157"><span class="linenos">157</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift.Generator-158"><a href="#Redshift.Generator-158"><span class="linenos">158</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="Redshift.Generator-159"><a href="#Redshift.Generator-159"><span class="linenos">159</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="Redshift.Generator-160"><a href="#Redshift.Generator-160"><span class="linenos">160</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">:</span> <span class="n">concat_ws_to_dpipe_sql</span><span class="p">,</span> -</span><span id="Redshift.Generator-161"><a href="#Redshift.Generator-161"><span class="linenos">161</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Redshift.Generator-162"><a href="#Redshift.Generator-162"><span class="linenos">162</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"APPROXIMATE COUNT(DISTINCT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</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="Redshift.Generator-163"><a href="#Redshift.Generator-163"><span class="linenos">163</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> -</span><span id="Redshift.Generator-164"><a href="#Redshift.Generator-164"><span class="linenos">164</span></a> <span class="s2">"SYSDATE"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"transaction"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"GETDATE()"</span> -</span><span id="Redshift.Generator-165"><a href="#Redshift.Generator-165"><span class="linenos">165</span></a> <span class="p">),</span> -</span><span id="Redshift.Generator-166"><a href="#Redshift.Generator-166"><span class="linenos">166</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> -</span><span id="Redshift.Generator-167"><a href="#Redshift.Generator-167"><span class="linenos">167</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> -</span><span id="Redshift.Generator-168"><a href="#Redshift.Generator-168"><span class="linenos">168</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DISTKEY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> -</span><span id="Redshift.Generator-169"><a href="#Redshift.Generator-169"><span class="linenos">169</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Redshift.Generator-170"><a href="#Redshift.Generator-170"><span class="linenos">170</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> -</span><span id="Redshift.Generator-171"><a href="#Redshift.Generator-171"><span class="linenos">171</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> <span class="n">generatedasidentitycolumnconstraint_sql</span><span class="p">,</span> -</span><span id="Redshift.Generator-172"><a href="#Redshift.Generator-172"><span class="linenos">172</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> -</span><span id="Redshift.Generator-173"><a href="#Redshift.Generator-173"><span class="linenos">173</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> -</span><span id="Redshift.Generator-174"><a href="#Redshift.Generator-174"><span class="linenos">174</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LISTAGG"</span><span class="p">),</span> -</span><span id="Redshift.Generator-175"><a href="#Redshift.Generator-175"><span class="linenos">175</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> -</span><span id="Redshift.Generator-176"><a href="#Redshift.Generator-176"><span class="linenos">176</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="Redshift.Generator-177"><a href="#Redshift.Generator-177"><span class="linenos">177</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="Redshift.Generator-178"><a href="#Redshift.Generator-178"><span class="linenos">178</span></a> <span class="p">[</span> -</span><span id="Redshift.Generator-179"><a href="#Redshift.Generator-179"><span class="linenos">179</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="Redshift.Generator-180"><a href="#Redshift.Generator-180"><span class="linenos">180</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="Redshift.Generator-181"><a href="#Redshift.Generator-181"><span class="linenos">181</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> -</span><span id="Redshift.Generator-182"><a href="#Redshift.Generator-182"><span class="linenos">182</span></a> <span class="p">]</span> -</span><span id="Redshift.Generator-183"><a href="#Redshift.Generator-183"><span class="linenos">183</span></a> <span class="p">),</span> -</span><span id="Redshift.Generator-184"><a href="#Redshift.Generator-184"><span class="linenos">184</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Redshift.Generator-185"><a href="#Redshift.Generator-185"><span class="linenos">185</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Redshift.Generator-186"><a href="#Redshift.Generator-186"><span class="linenos">186</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StartsWith</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Redshift.Generator-187"><a href="#Redshift.Generator-187"><span class="linenos">187</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> || '%'"</span><span class="p">,</span> -</span><span id="Redshift.Generator-188"><a href="#Redshift.Generator-188"><span class="linenos">188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> -</span><span id="Redshift.Generator-189"><a href="#Redshift.Generator-189"><span class="linenos">189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> -</span><span id="Redshift.Generator-190"><a href="#Redshift.Generator-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> -</span><span id="Redshift.Generator-191"><a href="#Redshift.Generator-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Redshift.Generator-192"><a href="#Redshift.Generator-192"><span class="linenos">192</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"(TIMESTAMP 'epoch' + </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> * INTERVAL '1 SECOND')"</span><span class="p">,</span> -</span><span id="Redshift.Generator-193"><a href="#Redshift.Generator-193"><span class="linenos">193</span></a> <span class="p">}</span> -</span><span id="Redshift.Generator-194"><a href="#Redshift.Generator-194"><span class="linenos">194</span></a> -</span><span id="Redshift.Generator-195"><a href="#Redshift.Generator-195"><span class="linenos">195</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> -</span><span id="Redshift.Generator-196"><a href="#Redshift.Generator-196"><span class="linenos">196</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> -</span><span id="Redshift.Generator-197"><a href="#Redshift.Generator-197"><span class="linenos">197</span></a> -</span><span id="Redshift.Generator-198"><a href="#Redshift.Generator-198"><span class="linenos">198</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> -</span><span id="Redshift.Generator-199"><a href="#Redshift.Generator-199"><span class="linenos">199</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> -</span><span id="Redshift.Generator-200"><a href="#Redshift.Generator-200"><span class="linenos">200</span></a> -</span><span id="Redshift.Generator-201"><a href="#Redshift.Generator-201"><span class="linenos">201</span></a> <span class="c1"># Redshift supports ANY_VALUE(..)</span> -</span><span id="Redshift.Generator-202"><a href="#Redshift.Generator-202"><span class="linenos">202</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">)</span> -</span><span id="Redshift.Generator-203"><a href="#Redshift.Generator-203"><span class="linenos">203</span></a> -</span><span id="Redshift.Generator-204"><a href="#Redshift.Generator-204"><span class="linenos">204</span></a> <span class="c1"># Redshift supports LAST_DAY(..)</span> -</span><span id="Redshift.Generator-205"><a href="#Redshift.Generator-205"><span class="linenos">205</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> -</span><span id="Redshift.Generator-206"><a href="#Redshift.Generator-206"><span class="linenos">206</span></a> -</span><span id="Redshift.Generator-207"><a href="#Redshift.Generator-207"><span class="linenos">207</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift.Generator-208"><a href="#Redshift.Generator-208"><span class="linenos">208</span></a> <span class="s2">"aes128"</span><span class="p">,</span> -</span><span id="Redshift.Generator-209"><a href="#Redshift.Generator-209"><span class="linenos">209</span></a> <span class="s2">"aes256"</span><span class="p">,</span> -</span><span id="Redshift.Generator-210"><a href="#Redshift.Generator-210"><span class="linenos">210</span></a> <span class="s2">"all"</span><span class="p">,</span> -</span><span id="Redshift.Generator-211"><a href="#Redshift.Generator-211"><span class="linenos">211</span></a> <span class="s2">"allowoverwrite"</span><span class="p">,</span> -</span><span id="Redshift.Generator-212"><a href="#Redshift.Generator-212"><span class="linenos">212</span></a> <span class="s2">"analyse"</span><span class="p">,</span> -</span><span id="Redshift.Generator-213"><a href="#Redshift.Generator-213"><span class="linenos">213</span></a> <span class="s2">"analyze"</span><span class="p">,</span> -</span><span id="Redshift.Generator-214"><a href="#Redshift.Generator-214"><span class="linenos">214</span></a> <span class="s2">"and"</span><span class="p">,</span> -</span><span id="Redshift.Generator-215"><a href="#Redshift.Generator-215"><span class="linenos">215</span></a> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="Redshift.Generator-216"><a href="#Redshift.Generator-216"><span class="linenos">216</span></a> <span class="s2">"array"</span><span class="p">,</span> -</span><span id="Redshift.Generator-217"><a href="#Redshift.Generator-217"><span class="linenos">217</span></a> <span class="s2">"as"</span><span class="p">,</span> -</span><span id="Redshift.Generator-218"><a href="#Redshift.Generator-218"><span class="linenos">218</span></a> <span class="s2">"asc"</span><span class="p">,</span> -</span><span id="Redshift.Generator-219"><a href="#Redshift.Generator-219"><span class="linenos">219</span></a> <span class="s2">"authorization"</span><span class="p">,</span> -</span><span id="Redshift.Generator-220"><a href="#Redshift.Generator-220"><span class="linenos">220</span></a> <span class="s2">"az64"</span><span class="p">,</span> -</span><span id="Redshift.Generator-221"><a href="#Redshift.Generator-221"><span class="linenos">221</span></a> <span class="s2">"backup"</span><span class="p">,</span> -</span><span id="Redshift.Generator-222"><a href="#Redshift.Generator-222"><span class="linenos">222</span></a> <span class="s2">"between"</span><span class="p">,</span> -</span><span id="Redshift.Generator-223"><a href="#Redshift.Generator-223"><span class="linenos">223</span></a> <span class="s2">"binary"</span><span class="p">,</span> -</span><span id="Redshift.Generator-224"><a href="#Redshift.Generator-224"><span class="linenos">224</span></a> <span class="s2">"blanksasnull"</span><span class="p">,</span> -</span><span id="Redshift.Generator-225"><a href="#Redshift.Generator-225"><span class="linenos">225</span></a> <span class="s2">"both"</span><span class="p">,</span> -</span><span id="Redshift.Generator-226"><a href="#Redshift.Generator-226"><span class="linenos">226</span></a> <span class="s2">"bytedict"</span><span class="p">,</span> -</span><span id="Redshift.Generator-227"><a href="#Redshift.Generator-227"><span class="linenos">227</span></a> <span class="s2">"bzip2"</span><span class="p">,</span> -</span><span id="Redshift.Generator-228"><a href="#Redshift.Generator-228"><span class="linenos">228</span></a> <span class="s2">"case"</span><span class="p">,</span> -</span><span id="Redshift.Generator-229"><a href="#Redshift.Generator-229"><span class="linenos">229</span></a> <span class="s2">"cast"</span><span class="p">,</span> -</span><span id="Redshift.Generator-230"><a href="#Redshift.Generator-230"><span class="linenos">230</span></a> <span class="s2">"check"</span><span class="p">,</span> -</span><span id="Redshift.Generator-231"><a href="#Redshift.Generator-231"><span class="linenos">231</span></a> <span class="s2">"collate"</span><span class="p">,</span> -</span><span id="Redshift.Generator-232"><a href="#Redshift.Generator-232"><span class="linenos">232</span></a> <span class="s2">"column"</span><span class="p">,</span> -</span><span id="Redshift.Generator-233"><a href="#Redshift.Generator-233"><span class="linenos">233</span></a> <span class="s2">"constraint"</span><span class="p">,</span> -</span><span id="Redshift.Generator-234"><a href="#Redshift.Generator-234"><span class="linenos">234</span></a> <span class="s2">"create"</span><span class="p">,</span> -</span><span id="Redshift.Generator-235"><a href="#Redshift.Generator-235"><span class="linenos">235</span></a> <span class="s2">"credentials"</span><span class="p">,</span> -</span><span id="Redshift.Generator-236"><a href="#Redshift.Generator-236"><span class="linenos">236</span></a> <span class="s2">"cross"</span><span class="p">,</span> -</span><span id="Redshift.Generator-237"><a href="#Redshift.Generator-237"><span class="linenos">237</span></a> <span class="s2">"current_date"</span><span class="p">,</span> -</span><span id="Redshift.Generator-238"><a href="#Redshift.Generator-238"><span class="linenos">238</span></a> <span class="s2">"current_time"</span><span class="p">,</span> -</span><span id="Redshift.Generator-239"><a href="#Redshift.Generator-239"><span class="linenos">239</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> -</span><span id="Redshift.Generator-240"><a href="#Redshift.Generator-240"><span class="linenos">240</span></a> <span class="s2">"current_user"</span><span class="p">,</span> -</span><span id="Redshift.Generator-241"><a href="#Redshift.Generator-241"><span class="linenos">241</span></a> <span class="s2">"current_user_id"</span><span class="p">,</span> -</span><span id="Redshift.Generator-242"><a href="#Redshift.Generator-242"><span class="linenos">242</span></a> <span class="s2">"default"</span><span class="p">,</span> -</span><span id="Redshift.Generator-243"><a href="#Redshift.Generator-243"><span class="linenos">243</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> -</span><span id="Redshift.Generator-244"><a href="#Redshift.Generator-244"><span class="linenos">244</span></a> <span class="s2">"deflate"</span><span class="p">,</span> -</span><span id="Redshift.Generator-245"><a href="#Redshift.Generator-245"><span class="linenos">245</span></a> <span class="s2">"defrag"</span><span class="p">,</span> -</span><span id="Redshift.Generator-246"><a href="#Redshift.Generator-246"><span class="linenos">246</span></a> <span class="s2">"delta"</span><span class="p">,</span> -</span><span id="Redshift.Generator-247"><a href="#Redshift.Generator-247"><span class="linenos">247</span></a> <span class="s2">"delta32k"</span><span class="p">,</span> -</span><span id="Redshift.Generator-248"><a href="#Redshift.Generator-248"><span class="linenos">248</span></a> <span class="s2">"desc"</span><span class="p">,</span> -</span><span id="Redshift.Generator-249"><a href="#Redshift.Generator-249"><span class="linenos">249</span></a> <span class="s2">"disable"</span><span class="p">,</span> -</span><span id="Redshift.Generator-250"><a href="#Redshift.Generator-250"><span class="linenos">250</span></a> <span class="s2">"distinct"</span><span class="p">,</span> -</span><span id="Redshift.Generator-251"><a href="#Redshift.Generator-251"><span class="linenos">251</span></a> <span class="s2">"do"</span><span class="p">,</span> -</span><span id="Redshift.Generator-252"><a href="#Redshift.Generator-252"><span class="linenos">252</span></a> <span class="s2">"else"</span><span class="p">,</span> -</span><span id="Redshift.Generator-253"><a href="#Redshift.Generator-253"><span class="linenos">253</span></a> <span class="s2">"emptyasnull"</span><span class="p">,</span> -</span><span id="Redshift.Generator-254"><a href="#Redshift.Generator-254"><span class="linenos">254</span></a> <span class="s2">"enable"</span><span class="p">,</span> -</span><span id="Redshift.Generator-255"><a href="#Redshift.Generator-255"><span class="linenos">255</span></a> <span class="s2">"encode"</span><span class="p">,</span> -</span><span id="Redshift.Generator-256"><a href="#Redshift.Generator-256"><span class="linenos">256</span></a> <span class="s2">"encrypt "</span><span class="p">,</span> -</span><span id="Redshift.Generator-257"><a href="#Redshift.Generator-257"><span class="linenos">257</span></a> <span class="s2">"encryption"</span><span class="p">,</span> -</span><span id="Redshift.Generator-258"><a href="#Redshift.Generator-258"><span class="linenos">258</span></a> <span class="s2">"end"</span><span class="p">,</span> -</span><span id="Redshift.Generator-259"><a href="#Redshift.Generator-259"><span class="linenos">259</span></a> <span class="s2">"except"</span><span class="p">,</span> -</span><span id="Redshift.Generator-260"><a href="#Redshift.Generator-260"><span class="linenos">260</span></a> <span class="s2">"explicit"</span><span class="p">,</span> -</span><span id="Redshift.Generator-261"><a href="#Redshift.Generator-261"><span class="linenos">261</span></a> <span class="s2">"false"</span><span class="p">,</span> -</span><span id="Redshift.Generator-262"><a href="#Redshift.Generator-262"><span class="linenos">262</span></a> <span class="s2">"for"</span><span class="p">,</span> -</span><span id="Redshift.Generator-263"><a href="#Redshift.Generator-263"><span class="linenos">263</span></a> <span class="s2">"foreign"</span><span class="p">,</span> -</span><span id="Redshift.Generator-264"><a href="#Redshift.Generator-264"><span class="linenos">264</span></a> <span class="s2">"freeze"</span><span class="p">,</span> -</span><span id="Redshift.Generator-265"><a href="#Redshift.Generator-265"><span class="linenos">265</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="Redshift.Generator-266"><a href="#Redshift.Generator-266"><span class="linenos">266</span></a> <span class="s2">"full"</span><span class="p">,</span> -</span><span id="Redshift.Generator-267"><a href="#Redshift.Generator-267"><span class="linenos">267</span></a> <span class="s2">"globaldict256"</span><span class="p">,</span> -</span><span id="Redshift.Generator-268"><a href="#Redshift.Generator-268"><span class="linenos">268</span></a> <span class="s2">"globaldict64k"</span><span class="p">,</span> -</span><span id="Redshift.Generator-269"><a href="#Redshift.Generator-269"><span class="linenos">269</span></a> <span class="s2">"grant"</span><span class="p">,</span> -</span><span id="Redshift.Generator-270"><a href="#Redshift.Generator-270"><span class="linenos">270</span></a> <span class="s2">"group"</span><span class="p">,</span> -</span><span id="Redshift.Generator-271"><a href="#Redshift.Generator-271"><span class="linenos">271</span></a> <span class="s2">"gzip"</span><span class="p">,</span> -</span><span id="Redshift.Generator-272"><a href="#Redshift.Generator-272"><span class="linenos">272</span></a> <span class="s2">"having"</span><span class="p">,</span> -</span><span id="Redshift.Generator-273"><a href="#Redshift.Generator-273"><span class="linenos">273</span></a> <span class="s2">"identity"</span><span class="p">,</span> -</span><span id="Redshift.Generator-274"><a href="#Redshift.Generator-274"><span class="linenos">274</span></a> <span class="s2">"ignore"</span><span class="p">,</span> -</span><span id="Redshift.Generator-275"><a href="#Redshift.Generator-275"><span class="linenos">275</span></a> <span class="s2">"ilike"</span><span class="p">,</span> -</span><span id="Redshift.Generator-276"><a href="#Redshift.Generator-276"><span class="linenos">276</span></a> <span class="s2">"in"</span><span class="p">,</span> -</span><span id="Redshift.Generator-277"><a href="#Redshift.Generator-277"><span class="linenos">277</span></a> <span class="s2">"initially"</span><span class="p">,</span> -</span><span id="Redshift.Generator-278"><a href="#Redshift.Generator-278"><span class="linenos">278</span></a> <span class="s2">"inner"</span><span class="p">,</span> -</span><span id="Redshift.Generator-279"><a href="#Redshift.Generator-279"><span class="linenos">279</span></a> <span class="s2">"intersect"</span><span class="p">,</span> -</span><span id="Redshift.Generator-280"><a href="#Redshift.Generator-280"><span class="linenos">280</span></a> <span class="s2">"interval"</span><span class="p">,</span> -</span><span id="Redshift.Generator-281"><a href="#Redshift.Generator-281"><span class="linenos">281</span></a> <span class="s2">"into"</span><span class="p">,</span> -</span><span id="Redshift.Generator-282"><a href="#Redshift.Generator-282"><span class="linenos">282</span></a> <span class="s2">"is"</span><span class="p">,</span> -</span><span id="Redshift.Generator-283"><a href="#Redshift.Generator-283"><span class="linenos">283</span></a> <span class="s2">"isnull"</span><span class="p">,</span> -</span><span id="Redshift.Generator-284"><a href="#Redshift.Generator-284"><span class="linenos">284</span></a> <span class="s2">"join"</span><span class="p">,</span> -</span><span id="Redshift.Generator-285"><a href="#Redshift.Generator-285"><span class="linenos">285</span></a> <span class="s2">"leading"</span><span class="p">,</span> -</span><span id="Redshift.Generator-286"><a href="#Redshift.Generator-286"><span class="linenos">286</span></a> <span class="s2">"left"</span><span class="p">,</span> -</span><span id="Redshift.Generator-287"><a href="#Redshift.Generator-287"><span class="linenos">287</span></a> <span class="s2">"like"</span><span class="p">,</span> -</span><span id="Redshift.Generator-288"><a href="#Redshift.Generator-288"><span class="linenos">288</span></a> <span class="s2">"limit"</span><span class="p">,</span> -</span><span id="Redshift.Generator-289"><a href="#Redshift.Generator-289"><span class="linenos">289</span></a> <span class="s2">"localtime"</span><span class="p">,</span> -</span><span id="Redshift.Generator-290"><a href="#Redshift.Generator-290"><span class="linenos">290</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> -</span><span id="Redshift.Generator-291"><a href="#Redshift.Generator-291"><span class="linenos">291</span></a> <span class="s2">"lun"</span><span class="p">,</span> -</span><span id="Redshift.Generator-292"><a href="#Redshift.Generator-292"><span class="linenos">292</span></a> <span class="s2">"luns"</span><span class="p">,</span> -</span><span id="Redshift.Generator-293"><a href="#Redshift.Generator-293"><span class="linenos">293</span></a> <span class="s2">"lzo"</span><span class="p">,</span> -</span><span id="Redshift.Generator-294"><a href="#Redshift.Generator-294"><span class="linenos">294</span></a> <span class="s2">"lzop"</span><span class="p">,</span> -</span><span id="Redshift.Generator-295"><a href="#Redshift.Generator-295"><span class="linenos">295</span></a> <span class="s2">"minus"</span><span class="p">,</span> -</span><span id="Redshift.Generator-296"><a href="#Redshift.Generator-296"><span class="linenos">296</span></a> <span class="s2">"mostly16"</span><span class="p">,</span> -</span><span id="Redshift.Generator-297"><a href="#Redshift.Generator-297"><span class="linenos">297</span></a> <span class="s2">"mostly32"</span><span class="p">,</span> -</span><span id="Redshift.Generator-298"><a href="#Redshift.Generator-298"><span class="linenos">298</span></a> <span class="s2">"mostly8"</span><span class="p">,</span> -</span><span id="Redshift.Generator-299"><a href="#Redshift.Generator-299"><span class="linenos">299</span></a> <span class="s2">"natural"</span><span class="p">,</span> -</span><span id="Redshift.Generator-300"><a href="#Redshift.Generator-300"><span class="linenos">300</span></a> <span class="s2">"new"</span><span class="p">,</span> -</span><span id="Redshift.Generator-301"><a href="#Redshift.Generator-301"><span class="linenos">301</span></a> <span class="s2">"not"</span><span class="p">,</span> -</span><span id="Redshift.Generator-302"><a href="#Redshift.Generator-302"><span class="linenos">302</span></a> <span class="s2">"notnull"</span><span class="p">,</span> -</span><span id="Redshift.Generator-303"><a href="#Redshift.Generator-303"><span class="linenos">303</span></a> <span class="s2">"null"</span><span class="p">,</span> -</span><span id="Redshift.Generator-304"><a href="#Redshift.Generator-304"><span class="linenos">304</span></a> <span class="s2">"nulls"</span><span class="p">,</span> -</span><span id="Redshift.Generator-305"><a href="#Redshift.Generator-305"><span class="linenos">305</span></a> <span class="s2">"off"</span><span class="p">,</span> -</span><span id="Redshift.Generator-306"><a href="#Redshift.Generator-306"><span class="linenos">306</span></a> <span class="s2">"offline"</span><span class="p">,</span> -</span><span id="Redshift.Generator-307"><a href="#Redshift.Generator-307"><span class="linenos">307</span></a> <span class="s2">"offset"</span><span class="p">,</span> -</span><span id="Redshift.Generator-308"><a href="#Redshift.Generator-308"><span class="linenos">308</span></a> <span class="s2">"oid"</span><span class="p">,</span> -</span><span id="Redshift.Generator-309"><a href="#Redshift.Generator-309"><span class="linenos">309</span></a> <span class="s2">"old"</span><span class="p">,</span> -</span><span id="Redshift.Generator-310"><a href="#Redshift.Generator-310"><span class="linenos">310</span></a> <span class="s2">"on"</span><span class="p">,</span> -</span><span id="Redshift.Generator-311"><a href="#Redshift.Generator-311"><span class="linenos">311</span></a> <span class="s2">"only"</span><span class="p">,</span> -</span><span id="Redshift.Generator-312"><a href="#Redshift.Generator-312"><span class="linenos">312</span></a> <span class="s2">"open"</span><span class="p">,</span> -</span><span id="Redshift.Generator-313"><a href="#Redshift.Generator-313"><span class="linenos">313</span></a> <span class="s2">"or"</span><span class="p">,</span> -</span><span id="Redshift.Generator-314"><a href="#Redshift.Generator-314"><span class="linenos">314</span></a> <span class="s2">"order"</span><span class="p">,</span> -</span><span id="Redshift.Generator-315"><a href="#Redshift.Generator-315"><span class="linenos">315</span></a> <span class="s2">"outer"</span><span class="p">,</span> -</span><span id="Redshift.Generator-316"><a href="#Redshift.Generator-316"><span class="linenos">316</span></a> <span class="s2">"overlaps"</span><span class="p">,</span> -</span><span id="Redshift.Generator-317"><a href="#Redshift.Generator-317"><span class="linenos">317</span></a> <span class="s2">"parallel"</span><span class="p">,</span> -</span><span id="Redshift.Generator-318"><a href="#Redshift.Generator-318"><span class="linenos">318</span></a> <span class="s2">"partition"</span><span class="p">,</span> -</span><span id="Redshift.Generator-319"><a href="#Redshift.Generator-319"><span class="linenos">319</span></a> <span class="s2">"percent"</span><span class="p">,</span> -</span><span id="Redshift.Generator-320"><a href="#Redshift.Generator-320"><span class="linenos">320</span></a> <span class="s2">"permissions"</span><span class="p">,</span> -</span><span id="Redshift.Generator-321"><a href="#Redshift.Generator-321"><span class="linenos">321</span></a> <span class="s2">"pivot"</span><span class="p">,</span> -</span><span id="Redshift.Generator-322"><a href="#Redshift.Generator-322"><span class="linenos">322</span></a> <span class="s2">"placing"</span><span class="p">,</span> -</span><span id="Redshift.Generator-323"><a href="#Redshift.Generator-323"><span class="linenos">323</span></a> <span class="s2">"primary"</span><span class="p">,</span> -</span><span id="Redshift.Generator-324"><a href="#Redshift.Generator-324"><span class="linenos">324</span></a> <span class="s2">"raw"</span><span class="p">,</span> -</span><span id="Redshift.Generator-325"><a href="#Redshift.Generator-325"><span class="linenos">325</span></a> <span class="s2">"readratio"</span><span class="p">,</span> -</span><span id="Redshift.Generator-326"><a href="#Redshift.Generator-326"><span class="linenos">326</span></a> <span class="s2">"recover"</span><span class="p">,</span> -</span><span id="Redshift.Generator-327"><a href="#Redshift.Generator-327"><span class="linenos">327</span></a> <span class="s2">"references"</span><span class="p">,</span> -</span><span id="Redshift.Generator-328"><a href="#Redshift.Generator-328"><span class="linenos">328</span></a> <span class="s2">"rejectlog"</span><span class="p">,</span> -</span><span id="Redshift.Generator-329"><a href="#Redshift.Generator-329"><span class="linenos">329</span></a> <span class="s2">"resort"</span><span class="p">,</span> -</span><span id="Redshift.Generator-330"><a href="#Redshift.Generator-330"><span class="linenos">330</span></a> <span class="s2">"respect"</span><span class="p">,</span> -</span><span id="Redshift.Generator-331"><a href="#Redshift.Generator-331"><span class="linenos">331</span></a> <span class="s2">"restore"</span><span class="p">,</span> -</span><span id="Redshift.Generator-332"><a href="#Redshift.Generator-332"><span class="linenos">332</span></a> <span class="s2">"right"</span><span class="p">,</span> -</span><span id="Redshift.Generator-333"><a href="#Redshift.Generator-333"><span class="linenos">333</span></a> <span class="s2">"select"</span><span class="p">,</span> -</span><span id="Redshift.Generator-334"><a href="#Redshift.Generator-334"><span class="linenos">334</span></a> <span class="s2">"session_user"</span><span class="p">,</span> -</span><span id="Redshift.Generator-335"><a href="#Redshift.Generator-335"><span class="linenos">335</span></a> <span class="s2">"similar"</span><span class="p">,</span> -</span><span id="Redshift.Generator-336"><a href="#Redshift.Generator-336"><span class="linenos">336</span></a> <span class="s2">"snapshot"</span><span class="p">,</span> -</span><span id="Redshift.Generator-337"><a href="#Redshift.Generator-337"><span class="linenos">337</span></a> <span class="s2">"some"</span><span class="p">,</span> -</span><span id="Redshift.Generator-338"><a href="#Redshift.Generator-338"><span class="linenos">338</span></a> <span class="s2">"sysdate"</span><span class="p">,</span> -</span><span id="Redshift.Generator-339"><a href="#Redshift.Generator-339"><span class="linenos">339</span></a> <span class="s2">"system"</span><span class="p">,</span> -</span><span id="Redshift.Generator-340"><a href="#Redshift.Generator-340"><span class="linenos">340</span></a> <span class="s2">"table"</span><span class="p">,</span> -</span><span id="Redshift.Generator-341"><a href="#Redshift.Generator-341"><span class="linenos">341</span></a> <span class="s2">"tag"</span><span class="p">,</span> -</span><span id="Redshift.Generator-342"><a href="#Redshift.Generator-342"><span class="linenos">342</span></a> <span class="s2">"tdes"</span><span class="p">,</span> -</span><span id="Redshift.Generator-343"><a href="#Redshift.Generator-343"><span class="linenos">343</span></a> <span class="s2">"text255"</span><span class="p">,</span> -</span><span id="Redshift.Generator-344"><a href="#Redshift.Generator-344"><span class="linenos">344</span></a> <span class="s2">"text32k"</span><span class="p">,</span> -</span><span id="Redshift.Generator-345"><a href="#Redshift.Generator-345"><span class="linenos">345</span></a> <span class="s2">"then"</span><span class="p">,</span> -</span><span id="Redshift.Generator-346"><a href="#Redshift.Generator-346"><span class="linenos">346</span></a> <span class="s2">"timestamp"</span><span class="p">,</span> -</span><span id="Redshift.Generator-347"><a href="#Redshift.Generator-347"><span class="linenos">347</span></a> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="Redshift.Generator-348"><a href="#Redshift.Generator-348"><span class="linenos">348</span></a> <span class="s2">"top"</span><span class="p">,</span> -</span><span id="Redshift.Generator-349"><a href="#Redshift.Generator-349"><span class="linenos">349</span></a> <span class="s2">"trailing"</span><span class="p">,</span> -</span><span id="Redshift.Generator-350"><a href="#Redshift.Generator-350"><span class="linenos">350</span></a> <span class="s2">"true"</span><span class="p">,</span> -</span><span id="Redshift.Generator-351"><a href="#Redshift.Generator-351"><span class="linenos">351</span></a> <span class="s2">"truncatecolumns"</span><span class="p">,</span> -</span><span id="Redshift.Generator-352"><a href="#Redshift.Generator-352"><span class="linenos">352</span></a> <span class="s2">"type"</span><span class="p">,</span> -</span><span id="Redshift.Generator-353"><a href="#Redshift.Generator-353"><span class="linenos">353</span></a> <span class="s2">"union"</span><span class="p">,</span> -</span><span id="Redshift.Generator-354"><a href="#Redshift.Generator-354"><span class="linenos">354</span></a> <span class="s2">"unique"</span><span class="p">,</span> -</span><span id="Redshift.Generator-355"><a href="#Redshift.Generator-355"><span class="linenos">355</span></a> <span class="s2">"unnest"</span><span class="p">,</span> -</span><span id="Redshift.Generator-356"><a href="#Redshift.Generator-356"><span class="linenos">356</span></a> <span class="s2">"unpivot"</span><span class="p">,</span> -</span><span id="Redshift.Generator-357"><a href="#Redshift.Generator-357"><span class="linenos">357</span></a> <span class="s2">"user"</span><span class="p">,</span> -</span><span id="Redshift.Generator-358"><a href="#Redshift.Generator-358"><span class="linenos">358</span></a> <span class="s2">"using"</span><span class="p">,</span> -</span><span id="Redshift.Generator-359"><a href="#Redshift.Generator-359"><span class="linenos">359</span></a> <span class="s2">"verbose"</span><span class="p">,</span> -</span><span id="Redshift.Generator-360"><a href="#Redshift.Generator-360"><span class="linenos">360</span></a> <span class="s2">"wallet"</span><span class="p">,</span> -</span><span id="Redshift.Generator-361"><a href="#Redshift.Generator-361"><span class="linenos">361</span></a> <span class="s2">"when"</span><span class="p">,</span> -</span><span id="Redshift.Generator-362"><a href="#Redshift.Generator-362"><span class="linenos">362</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="Redshift.Generator-363"><a href="#Redshift.Generator-363"><span class="linenos">363</span></a> <span class="s2">"with"</span><span class="p">,</span> -</span><span id="Redshift.Generator-364"><a href="#Redshift.Generator-364"><span class="linenos">364</span></a> <span class="s2">"without"</span><span class="p">,</span> -</span><span id="Redshift.Generator-365"><a href="#Redshift.Generator-365"><span class="linenos">365</span></a> <span class="p">}</span> -</span><span id="Redshift.Generator-366"><a href="#Redshift.Generator-366"><span class="linenos">366</span></a> -</span><span id="Redshift.Generator-367"><a href="#Redshift.Generator-367"><span class="linenos">367</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator-368"><a href="#Redshift.Generator-368"><span class="linenos">368</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Redshift.Generator-369"><a href="#Redshift.Generator-369"><span class="linenos">369</span></a> <span class="n">num_args</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> -</span><span id="Redshift.Generator-370"><a href="#Redshift.Generator-370"><span class="linenos">370</span></a> -</span><span id="Redshift.Generator-371"><a href="#Redshift.Generator-371"><span class="linenos">371</span></a> <span class="k">if</span> <span class="n">num_args</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Redshift.Generator-372"><a href="#Redshift.Generator-372"><span class="linenos">372</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported number of arguments in UNNEST: </span><span class="si">{</span><span class="n">num_args</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Redshift.Generator-373"><a href="#Redshift.Generator-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Redshift.Generator-374"><a href="#Redshift.Generator-374"><span class="linenos">374</span></a> -</span><span id="Redshift.Generator-375"><a href="#Redshift.Generator-375"><span class="linenos">375</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> -</span><span id="Redshift.Generator-376"><a href="#Redshift.Generator-376"><span class="linenos">376</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Redshift.Generator-377"><a href="#Redshift.Generator-377"><span class="linenos">377</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">arg</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">arg</span> -</span><span id="Redshift.Generator-378"><a href="#Redshift.Generator-378"><span class="linenos">378</span></a> -</span><span id="Redshift.Generator-379"><a href="#Redshift.Generator-379"><span class="linenos">379</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator-380"><a href="#Redshift.Generator-380"><span class="linenos">380</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> -</span><span id="Redshift.Generator-381"><a href="#Redshift.Generator-381"><span class="linenos">381</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Redshift.Generator-382"><a href="#Redshift.Generator-382"><span class="linenos">382</span></a> -</span><span id="Redshift.Generator-383"><a href="#Redshift.Generator-383"><span class="linenos">383</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator-384"><a href="#Redshift.Generator-384"><span class="linenos">384</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">JSON</span><span class="p">):</span> -</span><span id="Redshift.Generator-385"><a href="#Redshift.Generator-385"><span class="linenos">385</span></a> <span class="c1"># Redshift doesn't support a JSON type, so casting to it is treated as a noop</span> -</span><span id="Redshift.Generator-386"><a href="#Redshift.Generator-386"><span class="linenos">386</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Redshift.Generator-146"><a href="#Redshift.Generator-146"><span class="linenos">146</span></a> <span class="c1"># Redshift doesn't have `WITH` as part of their with_properties so we remove it</span> +</span><span id="Redshift.Generator-147"><a href="#Redshift.Generator-147"><span class="linenos">147</span></a> <span class="n">WITH_PROPERTIES_PREFIX</span> <span class="o">=</span> <span class="s2">" "</span> +</span><span id="Redshift.Generator-148"><a href="#Redshift.Generator-148"><span class="linenos">148</span></a> +</span><span id="Redshift.Generator-149"><a href="#Redshift.Generator-149"><span class="linenos">149</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift.Generator-150"><a href="#Redshift.Generator-150"><span class="linenos">150</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="Redshift.Generator-151"><a href="#Redshift.Generator-151"><span class="linenos">151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift.Generator-152"><a href="#Redshift.Generator-152"><span class="linenos">152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="Redshift.Generator-153"><a href="#Redshift.Generator-153"><span class="linenos">153</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMETZ</span><span class="p">:</span> <span class="s2">"TIME"</span><span class="p">,</span> +</span><span id="Redshift.Generator-154"><a href="#Redshift.Generator-154"><span class="linenos">154</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Redshift.Generator-155"><a href="#Redshift.Generator-155"><span class="linenos">155</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift.Generator-156"><a href="#Redshift.Generator-156"><span class="linenos">156</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift.Generator-157"><a href="#Redshift.Generator-157"><span class="linenos">157</span></a> <span class="p">}</span> +</span><span id="Redshift.Generator-158"><a href="#Redshift.Generator-158"><span class="linenos">158</span></a> +</span><span id="Redshift.Generator-159"><a href="#Redshift.Generator-159"><span class="linenos">159</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift.Generator-160"><a href="#Redshift.Generator-160"><span class="linenos">160</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="Redshift.Generator-161"><a href="#Redshift.Generator-161"><span class="linenos">161</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="Redshift.Generator-162"><a href="#Redshift.Generator-162"><span class="linenos">162</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">:</span> <span class="n">concat_ws_to_dpipe_sql</span><span class="p">,</span> +</span><span id="Redshift.Generator-163"><a href="#Redshift.Generator-163"><span class="linenos">163</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Redshift.Generator-164"><a href="#Redshift.Generator-164"><span class="linenos">164</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"APPROXIMATE COUNT(DISTINCT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</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="Redshift.Generator-165"><a href="#Redshift.Generator-165"><span class="linenos">165</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="p">(</span> +</span><span id="Redshift.Generator-166"><a href="#Redshift.Generator-166"><span class="linenos">166</span></a> <span class="s2">"SYSDATE"</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"transaction"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"GETDATE()"</span> +</span><span id="Redshift.Generator-167"><a href="#Redshift.Generator-167"><span class="linenos">167</span></a> <span class="p">),</span> +</span><span id="Redshift.Generator-168"><a href="#Redshift.Generator-168"><span class="linenos">168</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> +</span><span id="Redshift.Generator-169"><a href="#Redshift.Generator-169"><span class="linenos">169</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> +</span><span id="Redshift.Generator-170"><a href="#Redshift.Generator-170"><span class="linenos">170</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"DISTKEY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> +</span><span id="Redshift.Generator-171"><a href="#Redshift.Generator-171"><span class="linenos">171</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Redshift.Generator-172"><a href="#Redshift.Generator-172"><span class="linenos">172</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> +</span><span id="Redshift.Generator-173"><a href="#Redshift.Generator-173"><span class="linenos">173</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> <span class="n">generatedasidentitycolumnconstraint_sql</span><span class="p">,</span> +</span><span id="Redshift.Generator-174"><a href="#Redshift.Generator-174"><span class="linenos">174</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> +</span><span id="Redshift.Generator-175"><a href="#Redshift.Generator-175"><span class="linenos">175</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">json_extract_segments</span><span class="p">(</span><span class="s2">"JSON_EXTRACT_PATH_TEXT"</span><span class="p">),</span> +</span><span id="Redshift.Generator-176"><a href="#Redshift.Generator-176"><span class="linenos">176</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LISTAGG"</span><span class="p">),</span> +</span><span id="Redshift.Generator-177"><a href="#Redshift.Generator-177"><span class="linenos">177</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))),</span> +</span><span id="Redshift.Generator-178"><a href="#Redshift.Generator-178"><span class="linenos">178</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="Redshift.Generator-179"><a href="#Redshift.Generator-179"><span class="linenos">179</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="Redshift.Generator-180"><a href="#Redshift.Generator-180"><span class="linenos">180</span></a> <span class="p">[</span> +</span><span id="Redshift.Generator-181"><a href="#Redshift.Generator-181"><span class="linenos">181</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="Redshift.Generator-182"><a href="#Redshift.Generator-182"><span class="linenos">182</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="Redshift.Generator-183"><a href="#Redshift.Generator-183"><span class="linenos">183</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_unnest</span><span class="p">,</span> +</span><span id="Redshift.Generator-184"><a href="#Redshift.Generator-184"><span class="linenos">184</span></a> <span class="p">]</span> +</span><span id="Redshift.Generator-185"><a href="#Redshift.Generator-185"><span class="linenos">185</span></a> <span class="p">),</span> +</span><span id="Redshift.Generator-186"><a href="#Redshift.Generator-186"><span class="linenos">186</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Redshift.Generator-187"><a href="#Redshift.Generator-187"><span class="linenos">187</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Redshift.Generator-188"><a href="#Redshift.Generator-188"><span class="linenos">188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StartsWith</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Redshift.Generator-189"><a href="#Redshift.Generator-189"><span class="linenos">189</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> || '%'"</span><span class="p">,</span> +</span><span id="Redshift.Generator-190"><a href="#Redshift.Generator-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> +</span><span id="Redshift.Generator-191"><a href="#Redshift.Generator-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEADD"</span><span class="p">),</span> +</span><span id="Redshift.Generator-192"><a href="#Redshift.Generator-192"><span class="linenos">192</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="n">date_delta_sql</span><span class="p">(</span><span class="s2">"DATEDIFF"</span><span class="p">),</span> +</span><span id="Redshift.Generator-193"><a href="#Redshift.Generator-193"><span class="linenos">193</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Redshift.Generator-194"><a href="#Redshift.Generator-194"><span class="linenos">194</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"(TIMESTAMP 'epoch' + </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2"> * INTERVAL '1 SECOND')"</span><span class="p">,</span> +</span><span id="Redshift.Generator-195"><a href="#Redshift.Generator-195"><span class="linenos">195</span></a> <span class="p">}</span> +</span><span id="Redshift.Generator-196"><a href="#Redshift.Generator-196"><span class="linenos">196</span></a> +</span><span id="Redshift.Generator-197"><a href="#Redshift.Generator-197"><span class="linenos">197</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> +</span><span id="Redshift.Generator-198"><a href="#Redshift.Generator-198"><span class="linenos">198</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> +</span><span id="Redshift.Generator-199"><a href="#Redshift.Generator-199"><span class="linenos">199</span></a> +</span><span id="Redshift.Generator-200"><a href="#Redshift.Generator-200"><span class="linenos">200</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> +</span><span id="Redshift.Generator-201"><a href="#Redshift.Generator-201"><span class="linenos">201</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> +</span><span id="Redshift.Generator-202"><a href="#Redshift.Generator-202"><span class="linenos">202</span></a> +</span><span id="Redshift.Generator-203"><a href="#Redshift.Generator-203"><span class="linenos">203</span></a> <span class="c1"># Redshift supports ANY_VALUE(..)</span> +</span><span id="Redshift.Generator-204"><a href="#Redshift.Generator-204"><span class="linenos">204</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">AnyValue</span><span class="p">)</span> +</span><span id="Redshift.Generator-205"><a href="#Redshift.Generator-205"><span class="linenos">205</span></a> +</span><span id="Redshift.Generator-206"><a href="#Redshift.Generator-206"><span class="linenos">206</span></a> <span class="c1"># Redshift supports LAST_DAY(..)</span> +</span><span id="Redshift.Generator-207"><a href="#Redshift.Generator-207"><span class="linenos">207</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> +</span><span id="Redshift.Generator-208"><a href="#Redshift.Generator-208"><span class="linenos">208</span></a> +</span><span id="Redshift.Generator-209"><a href="#Redshift.Generator-209"><span class="linenos">209</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift.Generator-210"><a href="#Redshift.Generator-210"><span class="linenos">210</span></a> <span class="s2">"aes128"</span><span class="p">,</span> +</span><span id="Redshift.Generator-211"><a href="#Redshift.Generator-211"><span class="linenos">211</span></a> <span class="s2">"aes256"</span><span class="p">,</span> +</span><span id="Redshift.Generator-212"><a href="#Redshift.Generator-212"><span class="linenos">212</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="Redshift.Generator-213"><a href="#Redshift.Generator-213"><span class="linenos">213</span></a> <span class="s2">"allowoverwrite"</span><span class="p">,</span> +</span><span id="Redshift.Generator-214"><a href="#Redshift.Generator-214"><span class="linenos">214</span></a> <span class="s2">"analyse"</span><span class="p">,</span> +</span><span id="Redshift.Generator-215"><a href="#Redshift.Generator-215"><span class="linenos">215</span></a> <span class="s2">"analyze"</span><span class="p">,</span> +</span><span id="Redshift.Generator-216"><a href="#Redshift.Generator-216"><span class="linenos">216</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="Redshift.Generator-217"><a href="#Redshift.Generator-217"><span class="linenos">217</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="Redshift.Generator-218"><a href="#Redshift.Generator-218"><span class="linenos">218</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="Redshift.Generator-219"><a href="#Redshift.Generator-219"><span class="linenos">219</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="Redshift.Generator-220"><a href="#Redshift.Generator-220"><span class="linenos">220</span></a> <span class="s2">"asc"</span><span class="p">,</span> +</span><span id="Redshift.Generator-221"><a href="#Redshift.Generator-221"><span class="linenos">221</span></a> <span class="s2">"authorization"</span><span class="p">,</span> +</span><span id="Redshift.Generator-222"><a href="#Redshift.Generator-222"><span class="linenos">222</span></a> <span class="s2">"az64"</span><span class="p">,</span> +</span><span id="Redshift.Generator-223"><a href="#Redshift.Generator-223"><span class="linenos">223</span></a> <span class="s2">"backup"</span><span class="p">,</span> +</span><span id="Redshift.Generator-224"><a href="#Redshift.Generator-224"><span class="linenos">224</span></a> <span class="s2">"between"</span><span class="p">,</span> +</span><span id="Redshift.Generator-225"><a href="#Redshift.Generator-225"><span class="linenos">225</span></a> <span class="s2">"binary"</span><span class="p">,</span> +</span><span id="Redshift.Generator-226"><a href="#Redshift.Generator-226"><span class="linenos">226</span></a> <span class="s2">"blanksasnull"</span><span class="p">,</span> +</span><span id="Redshift.Generator-227"><a href="#Redshift.Generator-227"><span class="linenos">227</span></a> <span class="s2">"both"</span><span class="p">,</span> +</span><span id="Redshift.Generator-228"><a href="#Redshift.Generator-228"><span class="linenos">228</span></a> <span class="s2">"bytedict"</span><span class="p">,</span> +</span><span id="Redshift.Generator-229"><a href="#Redshift.Generator-229"><span class="linenos">229</span></a> <span class="s2">"bzip2"</span><span class="p">,</span> +</span><span id="Redshift.Generator-230"><a href="#Redshift.Generator-230"><span class="linenos">230</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="Redshift.Generator-231"><a href="#Redshift.Generator-231"><span class="linenos">231</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="Redshift.Generator-232"><a href="#Redshift.Generator-232"><span class="linenos">232</span></a> <span class="s2">"check"</span><span class="p">,</span> +</span><span id="Redshift.Generator-233"><a href="#Redshift.Generator-233"><span class="linenos">233</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="Redshift.Generator-234"><a href="#Redshift.Generator-234"><span class="linenos">234</span></a> <span class="s2">"column"</span><span class="p">,</span> +</span><span id="Redshift.Generator-235"><a href="#Redshift.Generator-235"><span class="linenos">235</span></a> <span class="s2">"constraint"</span><span class="p">,</span> +</span><span id="Redshift.Generator-236"><a href="#Redshift.Generator-236"><span class="linenos">236</span></a> <span class="s2">"create"</span><span class="p">,</span> +</span><span id="Redshift.Generator-237"><a href="#Redshift.Generator-237"><span class="linenos">237</span></a> <span class="s2">"credentials"</span><span class="p">,</span> +</span><span id="Redshift.Generator-238"><a href="#Redshift.Generator-238"><span class="linenos">238</span></a> <span class="s2">"cross"</span><span class="p">,</span> +</span><span id="Redshift.Generator-239"><a href="#Redshift.Generator-239"><span class="linenos">239</span></a> <span class="s2">"current_date"</span><span class="p">,</span> +</span><span id="Redshift.Generator-240"><a href="#Redshift.Generator-240"><span class="linenos">240</span></a> <span class="s2">"current_time"</span><span class="p">,</span> +</span><span id="Redshift.Generator-241"><a href="#Redshift.Generator-241"><span class="linenos">241</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> +</span><span id="Redshift.Generator-242"><a href="#Redshift.Generator-242"><span class="linenos">242</span></a> <span class="s2">"current_user"</span><span class="p">,</span> +</span><span id="Redshift.Generator-243"><a href="#Redshift.Generator-243"><span class="linenos">243</span></a> <span class="s2">"current_user_id"</span><span class="p">,</span> +</span><span id="Redshift.Generator-244"><a href="#Redshift.Generator-244"><span class="linenos">244</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="Redshift.Generator-245"><a href="#Redshift.Generator-245"><span class="linenos">245</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> +</span><span id="Redshift.Generator-246"><a href="#Redshift.Generator-246"><span class="linenos">246</span></a> <span class="s2">"deflate"</span><span class="p">,</span> +</span><span id="Redshift.Generator-247"><a href="#Redshift.Generator-247"><span class="linenos">247</span></a> <span class="s2">"defrag"</span><span class="p">,</span> +</span><span id="Redshift.Generator-248"><a href="#Redshift.Generator-248"><span class="linenos">248</span></a> <span class="s2">"delta"</span><span class="p">,</span> +</span><span id="Redshift.Generator-249"><a href="#Redshift.Generator-249"><span class="linenos">249</span></a> <span class="s2">"delta32k"</span><span class="p">,</span> +</span><span id="Redshift.Generator-250"><a href="#Redshift.Generator-250"><span class="linenos">250</span></a> <span class="s2">"desc"</span><span class="p">,</span> +</span><span id="Redshift.Generator-251"><a href="#Redshift.Generator-251"><span class="linenos">251</span></a> <span class="s2">"disable"</span><span class="p">,</span> +</span><span id="Redshift.Generator-252"><a href="#Redshift.Generator-252"><span class="linenos">252</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="Redshift.Generator-253"><a href="#Redshift.Generator-253"><span class="linenos">253</span></a> <span class="s2">"do"</span><span class="p">,</span> +</span><span id="Redshift.Generator-254"><a href="#Redshift.Generator-254"><span class="linenos">254</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="Redshift.Generator-255"><a href="#Redshift.Generator-255"><span class="linenos">255</span></a> <span class="s2">"emptyasnull"</span><span class="p">,</span> +</span><span id="Redshift.Generator-256"><a href="#Redshift.Generator-256"><span class="linenos">256</span></a> <span class="s2">"enable"</span><span class="p">,</span> +</span><span id="Redshift.Generator-257"><a href="#Redshift.Generator-257"><span class="linenos">257</span></a> <span class="s2">"encode"</span><span class="p">,</span> +</span><span id="Redshift.Generator-258"><a href="#Redshift.Generator-258"><span class="linenos">258</span></a> <span class="s2">"encrypt "</span><span class="p">,</span> +</span><span id="Redshift.Generator-259"><a href="#Redshift.Generator-259"><span class="linenos">259</span></a> <span class="s2">"encryption"</span><span class="p">,</span> +</span><span id="Redshift.Generator-260"><a href="#Redshift.Generator-260"><span class="linenos">260</span></a> <span class="s2">"end"</span><span class="p">,</span> +</span><span id="Redshift.Generator-261"><a href="#Redshift.Generator-261"><span class="linenos">261</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="Redshift.Generator-262"><a href="#Redshift.Generator-262"><span class="linenos">262</span></a> <span class="s2">"explicit"</span><span class="p">,</span> +</span><span id="Redshift.Generator-263"><a href="#Redshift.Generator-263"><span class="linenos">263</span></a> <span class="s2">"false"</span><span class="p">,</span> +</span><span id="Redshift.Generator-264"><a href="#Redshift.Generator-264"><span class="linenos">264</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="Redshift.Generator-265"><a href="#Redshift.Generator-265"><span class="linenos">265</span></a> <span class="s2">"foreign"</span><span class="p">,</span> +</span><span id="Redshift.Generator-266"><a href="#Redshift.Generator-266"><span class="linenos">266</span></a> <span class="s2">"freeze"</span><span class="p">,</span> +</span><span id="Redshift.Generator-267"><a href="#Redshift.Generator-267"><span class="linenos">267</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="Redshift.Generator-268"><a href="#Redshift.Generator-268"><span class="linenos">268</span></a> <span class="s2">"full"</span><span class="p">,</span> +</span><span id="Redshift.Generator-269"><a href="#Redshift.Generator-269"><span class="linenos">269</span></a> <span class="s2">"globaldict256"</span><span class="p">,</span> +</span><span id="Redshift.Generator-270"><a href="#Redshift.Generator-270"><span class="linenos">270</span></a> <span class="s2">"globaldict64k"</span><span class="p">,</span> +</span><span id="Redshift.Generator-271"><a href="#Redshift.Generator-271"><span class="linenos">271</span></a> <span class="s2">"grant"</span><span class="p">,</span> +</span><span id="Redshift.Generator-272"><a href="#Redshift.Generator-272"><span class="linenos">272</span></a> <span class="s2">"group"</span><span class="p">,</span> +</span><span id="Redshift.Generator-273"><a href="#Redshift.Generator-273"><span class="linenos">273</span></a> <span class="s2">"gzip"</span><span class="p">,</span> +</span><span id="Redshift.Generator-274"><a href="#Redshift.Generator-274"><span class="linenos">274</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="Redshift.Generator-275"><a href="#Redshift.Generator-275"><span class="linenos">275</span></a> <span class="s2">"identity"</span><span class="p">,</span> +</span><span id="Redshift.Generator-276"><a href="#Redshift.Generator-276"><span class="linenos">276</span></a> <span class="s2">"ignore"</span><span class="p">,</span> +</span><span id="Redshift.Generator-277"><a href="#Redshift.Generator-277"><span class="linenos">277</span></a> <span class="s2">"ilike"</span><span class="p">,</span> +</span><span id="Redshift.Generator-278"><a href="#Redshift.Generator-278"><span class="linenos">278</span></a> <span class="s2">"in"</span><span class="p">,</span> +</span><span id="Redshift.Generator-279"><a href="#Redshift.Generator-279"><span class="linenos">279</span></a> <span class="s2">"initially"</span><span class="p">,</span> +</span><span id="Redshift.Generator-280"><a href="#Redshift.Generator-280"><span class="linenos">280</span></a> <span class="s2">"inner"</span><span class="p">,</span> +</span><span id="Redshift.Generator-281"><a href="#Redshift.Generator-281"><span class="linenos">281</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="Redshift.Generator-282"><a href="#Redshift.Generator-282"><span class="linenos">282</span></a> <span class="s2">"interval"</span><span class="p">,</span> +</span><span id="Redshift.Generator-283"><a href="#Redshift.Generator-283"><span class="linenos">283</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="Redshift.Generator-284"><a href="#Redshift.Generator-284"><span class="linenos">284</span></a> <span class="s2">"is"</span><span class="p">,</span> +</span><span id="Redshift.Generator-285"><a href="#Redshift.Generator-285"><span class="linenos">285</span></a> <span class="s2">"isnull"</span><span class="p">,</span> +</span><span id="Redshift.Generator-286"><a href="#Redshift.Generator-286"><span class="linenos">286</span></a> <span class="s2">"join"</span><span class="p">,</span> +</span><span id="Redshift.Generator-287"><a href="#Redshift.Generator-287"><span class="linenos">287</span></a> <span class="s2">"leading"</span><span class="p">,</span> +</span><span id="Redshift.Generator-288"><a href="#Redshift.Generator-288"><span class="linenos">288</span></a> <span class="s2">"left"</span><span class="p">,</span> +</span><span id="Redshift.Generator-289"><a href="#Redshift.Generator-289"><span class="linenos">289</span></a> <span class="s2">"like"</span><span class="p">,</span> +</span><span id="Redshift.Generator-290"><a href="#Redshift.Generator-290"><span class="linenos">290</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="Redshift.Generator-291"><a href="#Redshift.Generator-291"><span class="linenos">291</span></a> <span class="s2">"localtime"</span><span class="p">,</span> +</span><span id="Redshift.Generator-292"><a href="#Redshift.Generator-292"><span class="linenos">292</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> +</span><span id="Redshift.Generator-293"><a href="#Redshift.Generator-293"><span class="linenos">293</span></a> <span class="s2">"lun"</span><span class="p">,</span> +</span><span id="Redshift.Generator-294"><a href="#Redshift.Generator-294"><span class="linenos">294</span></a> <span class="s2">"luns"</span><span class="p">,</span> +</span><span id="Redshift.Generator-295"><a href="#Redshift.Generator-295"><span class="linenos">295</span></a> <span class="s2">"lzo"</span><span class="p">,</span> +</span><span id="Redshift.Generator-296"><a href="#Redshift.Generator-296"><span class="linenos">296</span></a> <span class="s2">"lzop"</span><span class="p">,</span> +</span><span id="Redshift.Generator-297"><a href="#Redshift.Generator-297"><span class="linenos">297</span></a> <span class="s2">"minus"</span><span class="p">,</span> +</span><span id="Redshift.Generator-298"><a href="#Redshift.Generator-298"><span class="linenos">298</span></a> <span class="s2">"mostly16"</span><span class="p">,</span> +</span><span id="Redshift.Generator-299"><a href="#Redshift.Generator-299"><span class="linenos">299</span></a> <span class="s2">"mostly32"</span><span class="p">,</span> +</span><span id="Redshift.Generator-300"><a href="#Redshift.Generator-300"><span class="linenos">300</span></a> <span class="s2">"mostly8"</span><span class="p">,</span> +</span><span id="Redshift.Generator-301"><a href="#Redshift.Generator-301"><span class="linenos">301</span></a> <span class="s2">"natural"</span><span class="p">,</span> +</span><span id="Redshift.Generator-302"><a href="#Redshift.Generator-302"><span class="linenos">302</span></a> <span class="s2">"new"</span><span class="p">,</span> +</span><span id="Redshift.Generator-303"><a href="#Redshift.Generator-303"><span class="linenos">303</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="Redshift.Generator-304"><a href="#Redshift.Generator-304"><span class="linenos">304</span></a> <span class="s2">"notnull"</span><span class="p">,</span> +</span><span id="Redshift.Generator-305"><a href="#Redshift.Generator-305"><span class="linenos">305</span></a> <span class="s2">"null"</span><span class="p">,</span> +</span><span id="Redshift.Generator-306"><a href="#Redshift.Generator-306"><span class="linenos">306</span></a> <span class="s2">"nulls"</span><span class="p">,</span> +</span><span id="Redshift.Generator-307"><a href="#Redshift.Generator-307"><span class="linenos">307</span></a> <span class="s2">"off"</span><span class="p">,</span> +</span><span id="Redshift.Generator-308"><a href="#Redshift.Generator-308"><span class="linenos">308</span></a> <span class="s2">"offline"</span><span class="p">,</span> +</span><span id="Redshift.Generator-309"><a href="#Redshift.Generator-309"><span class="linenos">309</span></a> <span class="s2">"offset"</span><span class="p">,</span> +</span><span id="Redshift.Generator-310"><a href="#Redshift.Generator-310"><span class="linenos">310</span></a> <span class="s2">"oid"</span><span class="p">,</span> +</span><span id="Redshift.Generator-311"><a href="#Redshift.Generator-311"><span class="linenos">311</span></a> <span class="s2">"old"</span><span class="p">,</span> +</span><span id="Redshift.Generator-312"><a href="#Redshift.Generator-312"><span class="linenos">312</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="Redshift.Generator-313"><a href="#Redshift.Generator-313"><span class="linenos">313</span></a> <span class="s2">"only"</span><span class="p">,</span> +</span><span id="Redshift.Generator-314"><a href="#Redshift.Generator-314"><span class="linenos">314</span></a> <span class="s2">"open"</span><span class="p">,</span> +</span><span id="Redshift.Generator-315"><a href="#Redshift.Generator-315"><span class="linenos">315</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="Redshift.Generator-316"><a href="#Redshift.Generator-316"><span class="linenos">316</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="Redshift.Generator-317"><a href="#Redshift.Generator-317"><span class="linenos">317</span></a> <span class="s2">"outer"</span><span class="p">,</span> +</span><span id="Redshift.Generator-318"><a href="#Redshift.Generator-318"><span class="linenos">318</span></a> <span class="s2">"overlaps"</span><span class="p">,</span> +</span><span id="Redshift.Generator-319"><a href="#Redshift.Generator-319"><span class="linenos">319</span></a> <span class="s2">"parallel"</span><span class="p">,</span> +</span><span id="Redshift.Generator-320"><a href="#Redshift.Generator-320"><span class="linenos">320</span></a> <span class="s2">"partition"</span><span class="p">,</span> +</span><span id="Redshift.Generator-321"><a href="#Redshift.Generator-321"><span class="linenos">321</span></a> <span class="s2">"percent"</span><span class="p">,</span> +</span><span id="Redshift.Generator-322"><a href="#Redshift.Generator-322"><span class="linenos">322</span></a> <span class="s2">"permissions"</span><span class="p">,</span> +</span><span id="Redshift.Generator-323"><a href="#Redshift.Generator-323"><span class="linenos">323</span></a> <span class="s2">"pivot"</span><span class="p">,</span> +</span><span id="Redshift.Generator-324"><a href="#Redshift.Generator-324"><span class="linenos">324</span></a> <span class="s2">"placing"</span><span class="p">,</span> +</span><span id="Redshift.Generator-325"><a href="#Redshift.Generator-325"><span class="linenos">325</span></a> <span class="s2">"primary"</span><span class="p">,</span> +</span><span id="Redshift.Generator-326"><a href="#Redshift.Generator-326"><span class="linenos">326</span></a> <span class="s2">"raw"</span><span class="p">,</span> +</span><span id="Redshift.Generator-327"><a href="#Redshift.Generator-327"><span class="linenos">327</span></a> <span class="s2">"readratio"</span><span class="p">,</span> +</span><span id="Redshift.Generator-328"><a href="#Redshift.Generator-328"><span class="linenos">328</span></a> <span class="s2">"recover"</span><span class="p">,</span> +</span><span id="Redshift.Generator-329"><a href="#Redshift.Generator-329"><span class="linenos">329</span></a> <span class="s2">"references"</span><span class="p">,</span> +</span><span id="Redshift.Generator-330"><a href="#Redshift.Generator-330"><span class="linenos">330</span></a> <span class="s2">"rejectlog"</span><span class="p">,</span> +</span><span id="Redshift.Generator-331"><a href="#Redshift.Generator-331"><span class="linenos">331</span></a> <span class="s2">"resort"</span><span class="p">,</span> +</span><span id="Redshift.Generator-332"><a href="#Redshift.Generator-332"><span class="linenos">332</span></a> <span class="s2">"respect"</span><span class="p">,</span> +</span><span id="Redshift.Generator-333"><a href="#Redshift.Generator-333"><span class="linenos">333</span></a> <span class="s2">"restore"</span><span class="p">,</span> +</span><span id="Redshift.Generator-334"><a href="#Redshift.Generator-334"><span class="linenos">334</span></a> <span class="s2">"right"</span><span class="p">,</span> +</span><span id="Redshift.Generator-335"><a href="#Redshift.Generator-335"><span class="linenos">335</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="Redshift.Generator-336"><a href="#Redshift.Generator-336"><span class="linenos">336</span></a> <span class="s2">"session_user"</span><span class="p">,</span> +</span><span id="Redshift.Generator-337"><a href="#Redshift.Generator-337"><span class="linenos">337</span></a> <span class="s2">"similar"</span><span class="p">,</span> +</span><span id="Redshift.Generator-338"><a href="#Redshift.Generator-338"><span class="linenos">338</span></a> <span class="s2">"snapshot"</span><span class="p">,</span> +</span><span id="Redshift.Generator-339"><a href="#Redshift.Generator-339"><span class="linenos">339</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="Redshift.Generator-340"><a href="#Redshift.Generator-340"><span class="linenos">340</span></a> <span class="s2">"sysdate"</span><span class="p">,</span> +</span><span id="Redshift.Generator-341"><a href="#Redshift.Generator-341"><span class="linenos">341</span></a> <span class="s2">"system"</span><span class="p">,</span> +</span><span id="Redshift.Generator-342"><a href="#Redshift.Generator-342"><span class="linenos">342</span></a> <span class="s2">"table"</span><span class="p">,</span> +</span><span id="Redshift.Generator-343"><a href="#Redshift.Generator-343"><span class="linenos">343</span></a> <span class="s2">"tag"</span><span class="p">,</span> +</span><span id="Redshift.Generator-344"><a href="#Redshift.Generator-344"><span class="linenos">344</span></a> <span class="s2">"tdes"</span><span class="p">,</span> +</span><span id="Redshift.Generator-345"><a href="#Redshift.Generator-345"><span class="linenos">345</span></a> <span class="s2">"text255"</span><span class="p">,</span> +</span><span id="Redshift.Generator-346"><a href="#Redshift.Generator-346"><span class="linenos">346</span></a> <span class="s2">"text32k"</span><span class="p">,</span> +</span><span id="Redshift.Generator-347"><a href="#Redshift.Generator-347"><span class="linenos">347</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="Redshift.Generator-348"><a href="#Redshift.Generator-348"><span class="linenos">348</span></a> <span class="s2">"timestamp"</span><span class="p">,</span> +</span><span id="Redshift.Generator-349"><a href="#Redshift.Generator-349"><span class="linenos">349</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="Redshift.Generator-350"><a href="#Redshift.Generator-350"><span class="linenos">350</span></a> <span class="s2">"top"</span><span class="p">,</span> +</span><span id="Redshift.Generator-351"><a href="#Redshift.Generator-351"><span class="linenos">351</span></a> <span class="s2">"trailing"</span><span class="p">,</span> +</span><span id="Redshift.Generator-352"><a href="#Redshift.Generator-352"><span class="linenos">352</span></a> <span class="s2">"true"</span><span class="p">,</span> +</span><span id="Redshift.Generator-353"><a href="#Redshift.Generator-353"><span class="linenos">353</span></a> <span class="s2">"truncatecolumns"</span><span class="p">,</span> +</span><span id="Redshift.Generator-354"><a href="#Redshift.Generator-354"><span class="linenos">354</span></a> <span class="s2">"type"</span><span class="p">,</span> +</span><span id="Redshift.Generator-355"><a href="#Redshift.Generator-355"><span class="linenos">355</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="Redshift.Generator-356"><a href="#Redshift.Generator-356"><span class="linenos">356</span></a> <span class="s2">"unique"</span><span class="p">,</span> +</span><span id="Redshift.Generator-357"><a href="#Redshift.Generator-357"><span class="linenos">357</span></a> <span class="s2">"unnest"</span><span class="p">,</span> +</span><span id="Redshift.Generator-358"><a href="#Redshift.Generator-358"><span class="linenos">358</span></a> <span class="s2">"unpivot"</span><span class="p">,</span> +</span><span id="Redshift.Generator-359"><a href="#Redshift.Generator-359"><span class="linenos">359</span></a> <span class="s2">"user"</span><span class="p">,</span> +</span><span id="Redshift.Generator-360"><a href="#Redshift.Generator-360"><span class="linenos">360</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="Redshift.Generator-361"><a href="#Redshift.Generator-361"><span class="linenos">361</span></a> <span class="s2">"verbose"</span><span class="p">,</span> +</span><span id="Redshift.Generator-362"><a href="#Redshift.Generator-362"><span class="linenos">362</span></a> <span class="s2">"wallet"</span><span class="p">,</span> +</span><span id="Redshift.Generator-363"><a href="#Redshift.Generator-363"><span class="linenos">363</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="Redshift.Generator-364"><a href="#Redshift.Generator-364"><span class="linenos">364</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="Redshift.Generator-365"><a href="#Redshift.Generator-365"><span class="linenos">365</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="Redshift.Generator-366"><a href="#Redshift.Generator-366"><span class="linenos">366</span></a> <span class="s2">"without"</span><span class="p">,</span> +</span><span id="Redshift.Generator-367"><a href="#Redshift.Generator-367"><span class="linenos">367</span></a> <span class="p">}</span> +</span><span id="Redshift.Generator-368"><a href="#Redshift.Generator-368"><span class="linenos">368</span></a> +</span><span id="Redshift.Generator-369"><a href="#Redshift.Generator-369"><span class="linenos">369</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator-370"><a href="#Redshift.Generator-370"><span class="linenos">370</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Redshift.Generator-371"><a href="#Redshift.Generator-371"><span class="linenos">371</span></a> <span class="n">num_args</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> +</span><span id="Redshift.Generator-372"><a href="#Redshift.Generator-372"><span class="linenos">372</span></a> +</span><span id="Redshift.Generator-373"><a href="#Redshift.Generator-373"><span class="linenos">373</span></a> <span class="k">if</span> <span class="n">num_args</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Redshift.Generator-374"><a href="#Redshift.Generator-374"><span class="linenos">374</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported number of arguments in UNNEST: </span><span class="si">{</span><span class="n">num_args</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Redshift.Generator-375"><a href="#Redshift.Generator-375"><span class="linenos">375</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Redshift.Generator-376"><a href="#Redshift.Generator-376"><span class="linenos">376</span></a> +</span><span id="Redshift.Generator-377"><a href="#Redshift.Generator-377"><span class="linenos">377</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> +</span><span id="Redshift.Generator-378"><a href="#Redshift.Generator-378"><span class="linenos">378</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Redshift.Generator-379"><a href="#Redshift.Generator-379"><span class="linenos">379</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">arg</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">arg</span> +</span><span id="Redshift.Generator-380"><a href="#Redshift.Generator-380"><span class="linenos">380</span></a> +</span><span id="Redshift.Generator-381"><a href="#Redshift.Generator-381"><span class="linenos">381</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator-382"><a href="#Redshift.Generator-382"><span class="linenos">382</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">JSON</span><span class="p">):</span> +</span><span id="Redshift.Generator-383"><a href="#Redshift.Generator-383"><span class="linenos">383</span></a> <span class="c1"># Redshift doesn't support a JSON type, so casting to it is treated as a noop</span> +</span><span id="Redshift.Generator-384"><a href="#Redshift.Generator-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Redshift.Generator-385"><a href="#Redshift.Generator-385"><span class="linenos">385</span></a> +</span><span id="Redshift.Generator-386"><a href="#Redshift.Generator-386"><span class="linenos">386</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> </span><span id="Redshift.Generator-387"><a href="#Redshift.Generator-387"><span class="linenos">387</span></a> -</span><span id="Redshift.Generator-388"><a href="#Redshift.Generator-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> -</span><span id="Redshift.Generator-389"><a href="#Redshift.Generator-389"><span class="linenos">389</span></a> -</span><span id="Redshift.Generator-390"><a href="#Redshift.Generator-390"><span class="linenos">390</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator-391"><a href="#Redshift.Generator-391"><span class="linenos">391</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Redshift.Generator-392"><a href="#Redshift.Generator-392"><span class="linenos">392</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> -</span><span id="Redshift.Generator-393"><a href="#Redshift.Generator-393"><span class="linenos">393</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> -</span><span id="Redshift.Generator-394"><a href="#Redshift.Generator-394"><span class="linenos">394</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> -</span><span id="Redshift.Generator-395"><a href="#Redshift.Generator-395"><span class="linenos">395</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> -</span><span id="Redshift.Generator-396"><a href="#Redshift.Generator-396"><span class="linenos">396</span></a><span class="sd"> """</span> -</span><span id="Redshift.Generator-397"><a href="#Redshift.Generator-397"><span class="linenos">397</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> -</span><span id="Redshift.Generator-398"><a href="#Redshift.Generator-398"><span class="linenos">398</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span> -</span><span id="Redshift.Generator-399"><a href="#Redshift.Generator-399"><span class="linenos">399</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> -</span><span id="Redshift.Generator-400"><a href="#Redshift.Generator-400"><span class="linenos">400</span></a> -</span><span id="Redshift.Generator-401"><a href="#Redshift.Generator-401"><span class="linenos">401</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> -</span><span id="Redshift.Generator-402"><a href="#Redshift.Generator-402"><span class="linenos">402</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift.Generator-388"><a href="#Redshift.Generator-388"><span class="linenos">388</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator-389"><a href="#Redshift.Generator-389"><span class="linenos">389</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Redshift.Generator-390"><a href="#Redshift.Generator-390"><span class="linenos">390</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> +</span><span id="Redshift.Generator-391"><a href="#Redshift.Generator-391"><span class="linenos">391</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> +</span><span id="Redshift.Generator-392"><a href="#Redshift.Generator-392"><span class="linenos">392</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> +</span><span id="Redshift.Generator-393"><a href="#Redshift.Generator-393"><span class="linenos">393</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> +</span><span id="Redshift.Generator-394"><a href="#Redshift.Generator-394"><span class="linenos">394</span></a><span class="sd"> """</span> +</span><span id="Redshift.Generator-395"><a href="#Redshift.Generator-395"><span class="linenos">395</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> +</span><span id="Redshift.Generator-396"><a href="#Redshift.Generator-396"><span class="linenos">396</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span> +</span><span id="Redshift.Generator-397"><a href="#Redshift.Generator-397"><span class="linenos">397</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> +</span><span id="Redshift.Generator-398"><a href="#Redshift.Generator-398"><span class="linenos">398</span></a> +</span><span id="Redshift.Generator-399"><a href="#Redshift.Generator-399"><span class="linenos">399</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> +</span><span id="Redshift.Generator-400"><a href="#Redshift.Generator-400"><span class="linenos">400</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift.Generator-401"><a href="#Redshift.Generator-401"><span class="linenos">401</span></a> +</span><span id="Redshift.Generator-402"><a href="#Redshift.Generator-402"><span class="linenos">402</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="Redshift.Generator-403"><a href="#Redshift.Generator-403"><span class="linenos">403</span></a> -</span><span id="Redshift.Generator-404"><a href="#Redshift.Generator-404"><span class="linenos">404</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Redshift.Generator-404"><a href="#Redshift.Generator-404"><span class="linenos">404</span></a> <span class="k">def</span> <span class="nf">alterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator-405"><a href="#Redshift.Generator-405"><span class="linenos">405</span></a> <span class="n">exprs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Redshift.Generator-406"><a href="#Redshift.Generator-406"><span class="linenos">406</span></a> <span class="n">exprs</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TABLE PROPERTIES (</span><span class="si">{</span><span class="n">exprs</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">exprs</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Redshift.Generator-407"><a href="#Redshift.Generator-407"><span class="linenos">407</span></a> <span class="n">location</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"location"</span><span class="p">)</span> +</span><span id="Redshift.Generator-408"><a href="#Redshift.Generator-408"><span class="linenos">408</span></a> <span class="n">location</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LOCATION </span><span class="si">{</span><span class="n">location</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">location</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Redshift.Generator-409"><a href="#Redshift.Generator-409"><span class="linenos">409</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"file_format"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Redshift.Generator-410"><a href="#Redshift.Generator-410"><span class="linenos">410</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FILE FORMAT </span><span class="si">{</span><span class="n">file_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">file_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Redshift.Generator-411"><a href="#Redshift.Generator-411"><span class="linenos">411</span></a> +</span><span id="Redshift.Generator-412"><a href="#Redshift.Generator-412"><span class="linenos">412</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">exprs</span><span class="si">}{</span><span class="n">location</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -2304,6 +2332,18 @@ Default: True</li> </div> + <div id="Redshift.Generator.WITH_PROPERTIES_PREFIX" class="classattr"> + <div class="attr variable"> + <span class="name">WITH_PROPERTIES_PREFIX</span> = +<span class="default_value">' '</span> + + + </div> + <a class="headerlink" href="#Redshift.Generator.WITH_PROPERTIES_PREFIX"></a> + + + + </div> <div id="Redshift.Generator.TYPE_MAPPING" class="classattr"> <div class="attr variable"> <span class="name">TYPE_MAPPING</span> = @@ -2321,7 +2361,7 @@ Default: True</li> <div class="attr variable"> <span class="name">TRANSFORMS</span> = <input id="Redshift.Generator.TRANSFORMS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="Redshift.Generator.TRANSFORMS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>: <function json_path_key_only_name>, <class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#AllowedValuesProperty">sqlglot.expressions.AllowedValuesProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#AutoRefreshProperty">sqlglot.expressions.AutoRefreshProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#BackupProperty">sqlglot.expressions.BackupProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CaseSpecificColumnConstraint">sqlglot.expressions.CaseSpecificColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetColumnConstraint">sqlglot.expressions.CharacterSetColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetProperty">sqlglot.expressions.CharacterSetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ClusteredColumnConstraint">sqlglot.expressions.ClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CollateColumnConstraint">sqlglot.expressions.CollateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CopyGrantsProperty">sqlglot.expressions.CopyGrantsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DateFormatColumnConstraint">sqlglot.expressions.DateFormatColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DefaultColumnConstraint">sqlglot.expressions.DefaultColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EncodeColumnConstraint">sqlglot.expressions.EncodeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EphemeralColumnConstraint">sqlglot.expressions.EphemeralColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExcludeColumnConstraint">sqlglot.expressions.ExcludeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExecuteAsProperty">sqlglot.expressions.ExecuteAsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExternalProperty">sqlglot.expressions.ExternalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#GlobalProperty">sqlglot.expressions.GlobalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#HeapProperty">sqlglot.expressions.HeapProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IcebergProperty">sqlglot.expressions.IcebergProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InheritsProperty">sqlglot.expressions.InheritsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InlineLengthColumnConstraint">sqlglot.expressions.InlineLengthColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InputModelProperty">sqlglot.expressions.InputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IntervalSpan">sqlglot.expressions.IntervalSpan</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#JSONExtract">sqlglot.expressions.JSONExtract</a>'>: <function json_extract_segments.<locals>._json_extract_segments>, <class '<a href="../expressions.html#JSONExtractScalar">sqlglot.expressions.JSONExtractScalar</a>'>: <function json_extract_segments.<locals>._json_extract_segments>, <class '<a href="../expressions.html#LanguageProperty">sqlglot.expressions.LanguageProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LocationProperty">sqlglot.expressions.LocationProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LogProperty">sqlglot.expressions.LogProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#MaterializedProperty">sqlglot.expressions.MaterializedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NonClusteredColumnConstraint">sqlglot.expressions.NonClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NoPrimaryIndexProperty">sqlglot.expressions.NoPrimaryIndexProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NotForReplicationColumnConstraint">sqlglot.expressions.NotForReplicationColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnCommitProperty">sqlglot.expressions.OnCommitProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnProperty">sqlglot.expressions.OnProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnUpdateColumnConstraint">sqlglot.expressions.OnUpdateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OutputModelProperty">sqlglot.expressions.OutputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#PathColumnConstraint">sqlglot.expressions.PathColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#RemoteWithConnectionModelProperty">sqlglot.expressions.RemoteWithConnectionModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ReturnsProperty">sqlglot.expressions.ReturnsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SampleProperty">sqlglot.expressions.SampleProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetConfigProperty">sqlglot.expressions.SetConfigProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetProperty">sqlglot.expressions.SetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SettingsProperty">sqlglot.expressions.SettingsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SharingProperty">sqlglot.expressions.SharingProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlReadWriteProperty">sqlglot.expressions.SqlReadWriteProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlSecurityProperty">sqlglot.expressions.SqlSecurityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#StabilityProperty">sqlglot.expressions.StabilityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TemporaryProperty">sqlglot.expressions.TemporaryProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TitleColumnConstraint">sqlglot.expressions.TitleColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToTableProperty">sqlglot.expressions.ToTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransformModelProperty">sqlglot.expressions.TransformModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransientProperty">sqlglot.expressions.TransientProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UppercaseColumnConstraint">sqlglot.expressions.UppercaseColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UnloggedProperty">sqlglot.expressions.UnloggedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VarMap">sqlglot.expressions.VarMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ViewAttributeProperty">sqlglot.expressions.ViewAttributeProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VolatileProperty">sqlglot.expressions.VolatileProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithJournalTableProperty">sqlglot.expressions.WithJournalTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithOperator">sqlglot.expressions.WithOperator</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ArrayConcat">sqlglot.expressions.ArrayConcat</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArrayContained">sqlglot.expressions.ArrayContained</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ArrayOverlaps">sqlglot.expressions.ArrayOverlaps</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ArrayFilter">sqlglot.expressions.ArrayFilter</a>'>: <function filter_array_using_unnest>, <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#BitwiseXor">sqlglot.expressions.BitwiseXor</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ColumnDef">sqlglot.expressions.ColumnDef</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#CurrentDate">sqlglot.expressions.CurrentDate</a>'>: <function no_paren_current_date_sql>, <class '<a href="../expressions.html#CurrentTimestamp">sqlglot.expressions.CurrentTimestamp</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#CurrentUser">sqlglot.expressions.CurrentUser</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#DateAdd">sqlglot.expressions.DateAdd</a>'>: <function date_delta_sql.<locals>._delta_sql>, <class '<a href="../expressions.html#DateDiff">sqlglot.expressions.DateDiff</a>'>: <function date_delta_sql.<locals>._delta_sql>, <class '<a href="../expressions.html#DateStrToDate">sqlglot.expressions.DateStrToDate</a>'>: <function datestrtodate_sql>, <class '<a href="../expressions.html#DataType">sqlglot.expressions.DataType</a>'>: <function _datatype_sql>, <class '<a href="../expressions.html#DateSub">sqlglot.expressions.DateSub</a>'>: <function _date_add_sql.<locals>.func>, <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#GroupConcat">sqlglot.expressions.GroupConcat</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#JSONBExtract">sqlglot.expressions.JSONBExtract</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#JSONBExtractScalar">sqlglot.expressions.JSONBExtractScalar</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#JSONBContains">sqlglot.expressions.JSONBContains</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Max">sqlglot.expressions.Max</a>'>: <function max_or_greatest>, <class '<a href="../expressions.html#MapFromEntries">sqlglot.expressions.MapFromEntries</a>'>: <function no_map_from_entries_sql>, <class '<a href="../expressions.html#Min">sqlglot.expressions.Min</a>'>: <function min_or_least>, <class '<a href="../expressions.html#Merge">sqlglot.expressions.Merge</a>'>: <function merge_without_target_sql>, <class '<a href="../expressions.html#PartitionedByProperty">sqlglot.expressions.PartitionedByProperty</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#PercentileCont">sqlglot.expressions.PercentileCont</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#PercentileDisc">sqlglot.expressions.PercentileDisc</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#Rand">sqlglot.expressions.Rand</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#RegexpILike">sqlglot.expressions.RegexpILike</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#Select">sqlglot.expressions.Select</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#StrPosition">sqlglot.expressions.StrPosition</a>'>: <function str_position_sql>, <class '<a href="../expressions.html#StrToDate">sqlglot.expressions.StrToDate</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#StrToTime">sqlglot.expressions.StrToTime</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#StructExtract">sqlglot.expressions.StructExtract</a>'>: <function struct_extract_sql>, <class '<a href="../expressions.html#Substring">sqlglot.expressions.Substring</a>'>: <function _substring_sql>, <class '<a href="../expressions.html#TimeFromParts">sqlglot.expressions.TimeFromParts</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampFromParts">sqlglot.expressions.TimestampFromParts</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampTrunc">sqlglot.expressions.TimestampTrunc</a>'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class '<a href="../expressions.html#TimeStrToTime">sqlglot.expressions.TimeStrToTime</a>'>: <function timestrtotime_sql>, <class '<a href="../expressions.html#TimeToStr">sqlglot.expressions.TimeToStr</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ToChar">sqlglot.expressions.ToChar</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#Trim">sqlglot.expressions.Trim</a>'>: <function trim_sql>, <class '<a href="../expressions.html#TryCast">sqlglot.expressions.TryCast</a>'>: <function no_trycast_sql>, <class '<a href="../expressions.html#TsOrDsAdd">sqlglot.expressions.TsOrDsAdd</a>'>: <function date_delta_sql.<locals>._delta_sql>, <class '<a href="../expressions.html#TsOrDsDiff">sqlglot.expressions.TsOrDsDiff</a>'>: <function date_delta_sql.<locals>._delta_sql>, <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimeToUnix">sqlglot.expressions.TimeToUnix</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Xor">sqlglot.expressions.Xor</a>'>: <function bool_xor_sql>, <class '<a href="../expressions.html#Concat">sqlglot.expressions.Concat</a>'>: <function concat_to_dpipe_sql>, <class '<a href="../expressions.html#ConcatWs">sqlglot.expressions.ConcatWs</a>'>: <function concat_ws_to_dpipe_sql>, <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DistKeyProperty">sqlglot.expressions.DistKeyProperty</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DistStyleProperty">sqlglot.expressions.DistStyleProperty</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#FromBase">sqlglot.expressions.FromBase</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#GeneratedAsIdentityColumnConstraint">sqlglot.expressions.GeneratedAsIdentityColumnConstraint</a>'>: <function generatedasidentitycolumnconstraint_sql>, <class '<a href="../expressions.html#Hex">sqlglot.expressions.Hex</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#SortKeyProperty">sqlglot.expressions.SortKeyProperty</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#StartsWith">sqlglot.expressions.StartsWith</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TableSample">sqlglot.expressions.TableSample</a>'>: <function no_tablesample_sql>}</span> + <label class="view-value-button pdoc-button" for="Redshift.Generator.TRANSFORMS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>: <function json_path_key_only_name>, <class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#AllowedValuesProperty">sqlglot.expressions.AllowedValuesProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#AutoRefreshProperty">sqlglot.expressions.AutoRefreshProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#BackupProperty">sqlglot.expressions.BackupProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CaseSpecificColumnConstraint">sqlglot.expressions.CaseSpecificColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetColumnConstraint">sqlglot.expressions.CharacterSetColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetProperty">sqlglot.expressions.CharacterSetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ClusteredColumnConstraint">sqlglot.expressions.ClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CollateColumnConstraint">sqlglot.expressions.CollateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CopyGrantsProperty">sqlglot.expressions.CopyGrantsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DateFormatColumnConstraint">sqlglot.expressions.DateFormatColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DefaultColumnConstraint">sqlglot.expressions.DefaultColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EncodeColumnConstraint">sqlglot.expressions.EncodeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EphemeralColumnConstraint">sqlglot.expressions.EphemeralColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExcludeColumnConstraint">sqlglot.expressions.ExcludeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExecuteAsProperty">sqlglot.expressions.ExecuteAsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExternalProperty">sqlglot.expressions.ExternalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#GlobalProperty">sqlglot.expressions.GlobalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#HeapProperty">sqlglot.expressions.HeapProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IcebergProperty">sqlglot.expressions.IcebergProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InheritsProperty">sqlglot.expressions.InheritsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InlineLengthColumnConstraint">sqlglot.expressions.InlineLengthColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InputModelProperty">sqlglot.expressions.InputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IntervalSpan">sqlglot.expressions.IntervalSpan</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#JSONExtract">sqlglot.expressions.JSONExtract</a>'>: <function json_extract_segments.<locals>._json_extract_segments>, <class '<a href="../expressions.html#JSONExtractScalar">sqlglot.expressions.JSONExtractScalar</a>'>: <function json_extract_segments.<locals>._json_extract_segments>, <class '<a href="../expressions.html#LanguageProperty">sqlglot.expressions.LanguageProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LocationProperty">sqlglot.expressions.LocationProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LogProperty">sqlglot.expressions.LogProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#MaterializedProperty">sqlglot.expressions.MaterializedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NonClusteredColumnConstraint">sqlglot.expressions.NonClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NoPrimaryIndexProperty">sqlglot.expressions.NoPrimaryIndexProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NotForReplicationColumnConstraint">sqlglot.expressions.NotForReplicationColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnCommitProperty">sqlglot.expressions.OnCommitProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnProperty">sqlglot.expressions.OnProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnUpdateColumnConstraint">sqlglot.expressions.OnUpdateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OutputModelProperty">sqlglot.expressions.OutputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#PathColumnConstraint">sqlglot.expressions.PathColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#RemoteWithConnectionModelProperty">sqlglot.expressions.RemoteWithConnectionModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ReturnsProperty">sqlglot.expressions.ReturnsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SampleProperty">sqlglot.expressions.SampleProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetConfigProperty">sqlglot.expressions.SetConfigProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetProperty">sqlglot.expressions.SetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SettingsProperty">sqlglot.expressions.SettingsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SharingProperty">sqlglot.expressions.SharingProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlReadWriteProperty">sqlglot.expressions.SqlReadWriteProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlSecurityProperty">sqlglot.expressions.SqlSecurityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#StabilityProperty">sqlglot.expressions.StabilityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#StrictProperty">sqlglot.expressions.StrictProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TemporaryProperty">sqlglot.expressions.TemporaryProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TitleColumnConstraint">sqlglot.expressions.TitleColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToTableProperty">sqlglot.expressions.ToTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransformModelProperty">sqlglot.expressions.TransformModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransientProperty">sqlglot.expressions.TransientProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UppercaseColumnConstraint">sqlglot.expressions.UppercaseColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UnloggedProperty">sqlglot.expressions.UnloggedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VarMap">sqlglot.expressions.VarMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ViewAttributeProperty">sqlglot.expressions.ViewAttributeProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VolatileProperty">sqlglot.expressions.VolatileProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithJournalTableProperty">sqlglot.expressions.WithJournalTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithOperator">sqlglot.expressions.WithOperator</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ArrayConcat">sqlglot.expressions.ArrayConcat</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArrayContained">sqlglot.expressions.ArrayContained</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ArrayOverlaps">sqlglot.expressions.ArrayOverlaps</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ArrayFilter">sqlglot.expressions.ArrayFilter</a>'>: <function filter_array_using_unnest>, <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#BitwiseXor">sqlglot.expressions.BitwiseXor</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ColumnDef">sqlglot.expressions.ColumnDef</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#CurrentDate">sqlglot.expressions.CurrentDate</a>'>: <function no_paren_current_date_sql>, <class '<a href="../expressions.html#CurrentTimestamp">sqlglot.expressions.CurrentTimestamp</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#CurrentUser">sqlglot.expressions.CurrentUser</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#DateAdd">sqlglot.expressions.DateAdd</a>'>: <function date_delta_sql.<locals>._delta_sql>, <class '<a href="../expressions.html#DateDiff">sqlglot.expressions.DateDiff</a>'>: <function date_delta_sql.<locals>._delta_sql>, <class '<a href="../expressions.html#DateStrToDate">sqlglot.expressions.DateStrToDate</a>'>: <function datestrtodate_sql>, <class '<a href="../expressions.html#DataType">sqlglot.expressions.DataType</a>'>: <function _datatype_sql>, <class '<a href="../expressions.html#DateSub">sqlglot.expressions.DateSub</a>'>: <function _date_add_sql.<locals>.func>, <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#GroupConcat">sqlglot.expressions.GroupConcat</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#JSONBExtract">sqlglot.expressions.JSONBExtract</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#JSONBExtractScalar">sqlglot.expressions.JSONBExtractScalar</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#JSONBContains">sqlglot.expressions.JSONBContains</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Max">sqlglot.expressions.Max</a>'>: <function max_or_greatest>, <class '<a href="../expressions.html#MapFromEntries">sqlglot.expressions.MapFromEntries</a>'>: <function no_map_from_entries_sql>, <class '<a href="../expressions.html#Min">sqlglot.expressions.Min</a>'>: <function min_or_least>, <class '<a href="../expressions.html#Merge">sqlglot.expressions.Merge</a>'>: <function merge_without_target_sql>, <class '<a href="../expressions.html#PartitionedByProperty">sqlglot.expressions.PartitionedByProperty</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#PercentileCont">sqlglot.expressions.PercentileCont</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#PercentileDisc">sqlglot.expressions.PercentileDisc</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#Rand">sqlglot.expressions.Rand</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#RegexpILike">sqlglot.expressions.RegexpILike</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#Select">sqlglot.expressions.Select</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#StrPosition">sqlglot.expressions.StrPosition</a>'>: <function str_position_sql>, <class '<a href="../expressions.html#StrToDate">sqlglot.expressions.StrToDate</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#StrToTime">sqlglot.expressions.StrToTime</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#StructExtract">sqlglot.expressions.StructExtract</a>'>: <function struct_extract_sql>, <class '<a href="../expressions.html#Substring">sqlglot.expressions.Substring</a>'>: <function _substring_sql>, <class '<a href="../expressions.html#TimeFromParts">sqlglot.expressions.TimeFromParts</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampFromParts">sqlglot.expressions.TimestampFromParts</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#TimestampTrunc">sqlglot.expressions.TimestampTrunc</a>'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class '<a href="../expressions.html#TimeStrToTime">sqlglot.expressions.TimeStrToTime</a>'>: <function timestrtotime_sql>, <class '<a href="../expressions.html#TimeToStr">sqlglot.expressions.TimeToStr</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#ToChar">sqlglot.expressions.ToChar</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#Trim">sqlglot.expressions.Trim</a>'>: <function trim_sql>, <class '<a href="../expressions.html#TryCast">sqlglot.expressions.TryCast</a>'>: <function no_trycast_sql>, <class '<a href="../expressions.html#TsOrDsAdd">sqlglot.expressions.TsOrDsAdd</a>'>: <function date_delta_sql.<locals>._delta_sql>, <class '<a href="../expressions.html#TsOrDsDiff">sqlglot.expressions.TsOrDsDiff</a>'>: <function date_delta_sql.<locals>._delta_sql>, <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimeToUnix">sqlglot.expressions.TimeToUnix</a>'>: <function Postgres.Generator.<lambda>>, <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Xor">sqlglot.expressions.Xor</a>'>: <function bool_xor_sql>, <class '<a href="../expressions.html#Concat">sqlglot.expressions.Concat</a>'>: <function concat_to_dpipe_sql>, <class '<a href="../expressions.html#ConcatWs">sqlglot.expressions.ConcatWs</a>'>: <function concat_ws_to_dpipe_sql>, <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DistKeyProperty">sqlglot.expressions.DistKeyProperty</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DistStyleProperty">sqlglot.expressions.DistStyleProperty</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#FromBase">sqlglot.expressions.FromBase</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#GeneratedAsIdentityColumnConstraint">sqlglot.expressions.GeneratedAsIdentityColumnConstraint</a>'>: <function generatedasidentitycolumnconstraint_sql>, <class '<a href="../expressions.html#Hex">sqlglot.expressions.Hex</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#SortKeyProperty">sqlglot.expressions.SortKeyProperty</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#StartsWith">sqlglot.expressions.StartsWith</a>'>: <function <a href="#Redshift.Generator">Redshift.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TableSample">sqlglot.expressions.TableSample</a>'>: <function no_tablesample_sql>}</span> </div> @@ -2334,7 +2374,7 @@ Default: True</li> <div class="attr variable"> <span class="name">RESERVED_KEYWORDS</span> = <input id="Redshift.Generator.RESERVED_KEYWORDS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="Redshift.Generator.RESERVED_KEYWORDS-view-value"></label><span class="default_value">{'localtime', 'else', 'offset', 'without', 'like', 'group', 'type', 'intersect', 'verbose', 'end', 'from', 'isnull', 'case', 'deflate', 'old', 'all', 'cast', 'default', 'defrag', 'emptyasnull', 'overlaps', 'similar', 'union', 'in', 'az64', 'globaldict64k', 'binary', 'mostly32', 'wallet', 'current_date', 'minus', 'natural', 'system', 'top', 'unpivot', 'current_time', 'left', 'between', 'with', 'array', 'order', 'leading', 'and', 'for', 'rejectlog', 'sysdate', 'distinct', 'select', 'current_user', 'when', 'permissions', 'identity', 'except', 'new', 'into', 'any', 'current_timestamp', 'is', 'on', 'analyse', 'inner', 'null', 'join', 'full', 'lun', 'desc', 'do', 'delta', 'bytedict', 'freeze', 'resort', 'constraint', 'interval', 'text32k', 'foreign', 'using', 'table', 'recover', 'both', 'percent', 'tdes', 'collate', 'respect', 'initially', 'encode', 'session_user', 'right', 'some', 'localtimestamp', 'analyze', 'deferrable', 'encrypt ', 'create', 'gzip', 'lzop', 'tag', 'check', 'parallel', 'placing', 'encryption', 'backup', 'then', 'cross', 'credentials', 'primary', 'partition', 'where', 'notnull', 'pivot', 'limit', 'or', 'authorization', 'unique', 'off', 'false', 'enable', 'ignore', 'lzo', 'restore', 'references', 'text255', 'allowoverwrite', 'unnest', 'outer', 'aes256', 'blanksasnull', 'raw', 'trailing', 'only', 'readratio', 'truncatecolumns', 'nulls', 'user', 'snapshot', 'timestamp', 'to', 'grant', 'asc', 'explicit', 'having', 'not', 'ilike', 'column', 'delta32k', 'offline', 'as', 'globaldict256', 'aes128', 'mostly16', 'true', 'oid', 'open', 'mostly8', 'current_user_id', 'disable', 'luns', 'bzip2'}</span> + <label class="view-value-button pdoc-button" for="Redshift.Generator.RESERVED_KEYWORDS-view-value"></label><span class="default_value">{'similar', 'binary', 'cross', 'wallet', 'false', 'restore', 'aes128', 'analyze', 'timestamp', 'some', 'then', 'unnest', 'lzop', 'for', 'right', 'explicit', 'any', 'all', 'old', 'true', 'isnull', 'union', 'desc', 'emptyasnull', 'pivot', 'offline', 'type', 'encryption', 'create', 'deferrable', 'outer', 'using', 'identity', 'when', 'table', 'analyse', 'off', 'full', 'respect', 'system', 'else', 'leading', 'lun', 'authorization', 'foreign', 'end', 'asc', 'parallel', 'do', 'recover', 'mostly8', 'ilike', 'both', 'new', 'natural', 'check', 'session_user', 'with', 'luns', 'globaldict256', 'interval', 'is', 'verbose', 'current_user_id', 'from', 'bytedict', 'credentials', 'minus', 'resort', 'snapshot', 'aes256', 'and', 'like', 'disable', 'default', 'cast', 'inner', 'initially', 'except', 'nulls', 'localtimestamp', 'unpivot', 'delta32k', 'open', 'lzo', 'without', 'encode', 'mostly16', 'bzip2', 'trailing', 'having', 'permissions', 'join', 'overlaps', 'text32k', 'constraint', 'collate', 'deflate', 'current_date', 'case', 'primary', 'in', 'mostly32', 'percent', 'column', 'sysdate', 'gzip', 'truncatecolumns', 'az64', 'references', 'top', 'localtime', 'or', 'between', 'current_timestamp', 'tag', 'tdes', 'backup', 'current_time', 'blanksasnull', 'intersect', 'distinct', 'globaldict64k', 'on', 'only', 'readratio', 'current_user', 'grant', 'raw', 'not', 'group', 'text255', 'limit', 'into', 'user', 'encrypt ', 'left', 'enable', 'as', 'select', 'partition', 'placing', 'unique', 'offset', 'where', 'array', 'oid', 'null', 'freeze', 'to', 'order', 'delta', 'allowoverwrite', 'ignore', 'notnull', 'defrag', 'rejectlog'}</span> </div> @@ -2354,45 +2394,23 @@ Default: True</li> </div> <a class="headerlink" href="#Redshift.Generator.unnest_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.unnest_sql-367"><a href="#Redshift.Generator.unnest_sql-367"><span class="linenos">367</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator.unnest_sql-368"><a href="#Redshift.Generator.unnest_sql-368"><span class="linenos">368</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Redshift.Generator.unnest_sql-369"><a href="#Redshift.Generator.unnest_sql-369"><span class="linenos">369</span></a> <span class="n">num_args</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> -</span><span id="Redshift.Generator.unnest_sql-370"><a href="#Redshift.Generator.unnest_sql-370"><span class="linenos">370</span></a> -</span><span id="Redshift.Generator.unnest_sql-371"><a href="#Redshift.Generator.unnest_sql-371"><span class="linenos">371</span></a> <span class="k">if</span> <span class="n">num_args</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Redshift.Generator.unnest_sql-372"><a href="#Redshift.Generator.unnest_sql-372"><span class="linenos">372</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported number of arguments in UNNEST: </span><span class="si">{</span><span class="n">num_args</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Redshift.Generator.unnest_sql-373"><a href="#Redshift.Generator.unnest_sql-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Redshift.Generator.unnest_sql-374"><a href="#Redshift.Generator.unnest_sql-374"><span class="linenos">374</span></a> -</span><span id="Redshift.Generator.unnest_sql-375"><a href="#Redshift.Generator.unnest_sql-375"><span class="linenos">375</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> -</span><span id="Redshift.Generator.unnest_sql-376"><a href="#Redshift.Generator.unnest_sql-376"><span class="linenos">376</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Redshift.Generator.unnest_sql-377"><a href="#Redshift.Generator.unnest_sql-377"><span class="linenos">377</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">arg</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">arg</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.unnest_sql-369"><a href="#Redshift.Generator.unnest_sql-369"><span class="linenos">369</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator.unnest_sql-370"><a href="#Redshift.Generator.unnest_sql-370"><span class="linenos">370</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Redshift.Generator.unnest_sql-371"><a href="#Redshift.Generator.unnest_sql-371"><span class="linenos">371</span></a> <span class="n">num_args</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> +</span><span id="Redshift.Generator.unnest_sql-372"><a href="#Redshift.Generator.unnest_sql-372"><span class="linenos">372</span></a> +</span><span id="Redshift.Generator.unnest_sql-373"><a href="#Redshift.Generator.unnest_sql-373"><span class="linenos">373</span></a> <span class="k">if</span> <span class="n">num_args</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Redshift.Generator.unnest_sql-374"><a href="#Redshift.Generator.unnest_sql-374"><span class="linenos">374</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported number of arguments in UNNEST: </span><span class="si">{</span><span class="n">num_args</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Redshift.Generator.unnest_sql-375"><a href="#Redshift.Generator.unnest_sql-375"><span class="linenos">375</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Redshift.Generator.unnest_sql-376"><a href="#Redshift.Generator.unnest_sql-376"><span class="linenos">376</span></a> +</span><span id="Redshift.Generator.unnest_sql-377"><a href="#Redshift.Generator.unnest_sql-377"><span class="linenos">377</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> +</span><span id="Redshift.Generator.unnest_sql-378"><a href="#Redshift.Generator.unnest_sql-378"><span class="linenos">378</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">),</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Redshift.Generator.unnest_sql-379"><a href="#Redshift.Generator.unnest_sql-379"><span class="linenos">379</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">arg</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">arg</span> </span></pre></div> </div> - <div id="Redshift.Generator.with_properties" class="classattr"> - <input id="Redshift.Generator.with_properties-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> -<div class="attr function"> - - <span class="def">def</span> - <span class="name">with_properties</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">properties</span><span class="p">:</span> <span class="n"><a href="../expressions.html#Properties">sqlglot.expressions.Properties</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> - - <label class="view-source-button" for="Redshift.Generator.with_properties-view-source"><span>View Source</span></label> - - </div> - <a class="headerlink" href="#Redshift.Generator.with_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.with_properties-379"><a href="#Redshift.Generator.with_properties-379"><span class="linenos">379</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator.with_properties-380"><a href="#Redshift.Generator.with_properties-380"><span class="linenos">380</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> -</span><span id="Redshift.Generator.with_properties-381"><a href="#Redshift.Generator.with_properties-381"><span class="linenos">381</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span></pre></div> - - - <div class="docstring"><p>Redshift doesn't have <code>WITH</code> as part of their with_properties so we remove it</p> -</div> - - - </div> <div id="Redshift.Generator.cast_sql" class="classattr"> <input id="Redshift.Generator.cast_sql-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> <div class="attr function"> @@ -2404,12 +2422,12 @@ Default: True</li> </div> <a class="headerlink" href="#Redshift.Generator.cast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.cast_sql-383"><a href="#Redshift.Generator.cast_sql-383"><span class="linenos">383</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator.cast_sql-384"><a href="#Redshift.Generator.cast_sql-384"><span class="linenos">384</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">JSON</span><span class="p">):</span> -</span><span id="Redshift.Generator.cast_sql-385"><a href="#Redshift.Generator.cast_sql-385"><span class="linenos">385</span></a> <span class="c1"># Redshift doesn't support a JSON type, so casting to it is treated as a noop</span> -</span><span id="Redshift.Generator.cast_sql-386"><a href="#Redshift.Generator.cast_sql-386"><span class="linenos">386</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Redshift.Generator.cast_sql-387"><a href="#Redshift.Generator.cast_sql-387"><span class="linenos">387</span></a> -</span><span id="Redshift.Generator.cast_sql-388"><a href="#Redshift.Generator.cast_sql-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.cast_sql-381"><a href="#Redshift.Generator.cast_sql-381"><span class="linenos">381</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator.cast_sql-382"><a href="#Redshift.Generator.cast_sql-382"><span class="linenos">382</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">JSON</span><span class="p">):</span> +</span><span id="Redshift.Generator.cast_sql-383"><a href="#Redshift.Generator.cast_sql-383"><span class="linenos">383</span></a> <span class="c1"># Redshift doesn't support a JSON type, so casting to it is treated as a noop</span> +</span><span id="Redshift.Generator.cast_sql-384"><a href="#Redshift.Generator.cast_sql-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Redshift.Generator.cast_sql-385"><a href="#Redshift.Generator.cast_sql-385"><span class="linenos">385</span></a> +</span><span id="Redshift.Generator.cast_sql-386"><a href="#Redshift.Generator.cast_sql-386"><span class="linenos">386</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> </span></pre></div> @@ -2427,21 +2445,21 @@ Default: True</li> </div> <a class="headerlink" href="#Redshift.Generator.datatype_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.datatype_sql-390"><a href="#Redshift.Generator.datatype_sql-390"><span class="linenos">390</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator.datatype_sql-391"><a href="#Redshift.Generator.datatype_sql-391"><span class="linenos">391</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Redshift.Generator.datatype_sql-392"><a href="#Redshift.Generator.datatype_sql-392"><span class="linenos">392</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> -</span><span id="Redshift.Generator.datatype_sql-393"><a href="#Redshift.Generator.datatype_sql-393"><span class="linenos">393</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> -</span><span id="Redshift.Generator.datatype_sql-394"><a href="#Redshift.Generator.datatype_sql-394"><span class="linenos">394</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> -</span><span id="Redshift.Generator.datatype_sql-395"><a href="#Redshift.Generator.datatype_sql-395"><span class="linenos">395</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> -</span><span id="Redshift.Generator.datatype_sql-396"><a href="#Redshift.Generator.datatype_sql-396"><span class="linenos">396</span></a><span class="sd"> """</span> -</span><span id="Redshift.Generator.datatype_sql-397"><a href="#Redshift.Generator.datatype_sql-397"><span class="linenos">397</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> -</span><span id="Redshift.Generator.datatype_sql-398"><a href="#Redshift.Generator.datatype_sql-398"><span class="linenos">398</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span> -</span><span id="Redshift.Generator.datatype_sql-399"><a href="#Redshift.Generator.datatype_sql-399"><span class="linenos">399</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> -</span><span id="Redshift.Generator.datatype_sql-400"><a href="#Redshift.Generator.datatype_sql-400"><span class="linenos">400</span></a> -</span><span id="Redshift.Generator.datatype_sql-401"><a href="#Redshift.Generator.datatype_sql-401"><span class="linenos">401</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> -</span><span id="Redshift.Generator.datatype_sql-402"><a href="#Redshift.Generator.datatype_sql-402"><span class="linenos">402</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> -</span><span id="Redshift.Generator.datatype_sql-403"><a href="#Redshift.Generator.datatype_sql-403"><span class="linenos">403</span></a> -</span><span id="Redshift.Generator.datatype_sql-404"><a href="#Redshift.Generator.datatype_sql-404"><span class="linenos">404</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.datatype_sql-388"><a href="#Redshift.Generator.datatype_sql-388"><span class="linenos">388</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator.datatype_sql-389"><a href="#Redshift.Generator.datatype_sql-389"><span class="linenos">389</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Redshift.Generator.datatype_sql-390"><a href="#Redshift.Generator.datatype_sql-390"><span class="linenos">390</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> +</span><span id="Redshift.Generator.datatype_sql-391"><a href="#Redshift.Generator.datatype_sql-391"><span class="linenos">391</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> +</span><span id="Redshift.Generator.datatype_sql-392"><a href="#Redshift.Generator.datatype_sql-392"><span class="linenos">392</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> +</span><span id="Redshift.Generator.datatype_sql-393"><a href="#Redshift.Generator.datatype_sql-393"><span class="linenos">393</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> +</span><span id="Redshift.Generator.datatype_sql-394"><a href="#Redshift.Generator.datatype_sql-394"><span class="linenos">394</span></a><span class="sd"> """</span> +</span><span id="Redshift.Generator.datatype_sql-395"><a href="#Redshift.Generator.datatype_sql-395"><span class="linenos">395</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">):</span> +</span><span id="Redshift.Generator.datatype_sql-396"><a href="#Redshift.Generator.datatype_sql-396"><span class="linenos">396</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span> +</span><span id="Redshift.Generator.datatype_sql-397"><a href="#Redshift.Generator.datatype_sql-397"><span class="linenos">397</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> +</span><span id="Redshift.Generator.datatype_sql-398"><a href="#Redshift.Generator.datatype_sql-398"><span class="linenos">398</span></a> +</span><span id="Redshift.Generator.datatype_sql-399"><a href="#Redshift.Generator.datatype_sql-399"><span class="linenos">399</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> +</span><span id="Redshift.Generator.datatype_sql-400"><a href="#Redshift.Generator.datatype_sql-400"><span class="linenos">400</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift.Generator.datatype_sql-401"><a href="#Redshift.Generator.datatype_sql-401"><span class="linenos">401</span></a> +</span><span id="Redshift.Generator.datatype_sql-402"><a href="#Redshift.Generator.datatype_sql-402"><span class="linenos">402</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2453,6 +2471,32 @@ without precision we convert it to <code>VARCHAR(max)</code> and if it does have </div> + <div id="Redshift.Generator.alterset_sql" class="classattr"> + <input id="Redshift.Generator.alterset_sql-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + + <span class="def">def</span> + <span class="name">alterset_sql</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">expression</span><span class="p">:</span> <span class="n"><a href="../expressions.html#AlterSet">sqlglot.expressions.AlterSet</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> + + <label class="view-source-button" for="Redshift.Generator.alterset_sql-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Redshift.Generator.alterset_sql"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.alterset_sql-404"><a href="#Redshift.Generator.alterset_sql-404"><span class="linenos">404</span></a> <span class="k">def</span> <span class="nf">alterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator.alterset_sql-405"><a href="#Redshift.Generator.alterset_sql-405"><span class="linenos">405</span></a> <span class="n">exprs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Redshift.Generator.alterset_sql-406"><a href="#Redshift.Generator.alterset_sql-406"><span class="linenos">406</span></a> <span class="n">exprs</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TABLE PROPERTIES (</span><span class="si">{</span><span class="n">exprs</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">exprs</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Redshift.Generator.alterset_sql-407"><a href="#Redshift.Generator.alterset_sql-407"><span class="linenos">407</span></a> <span class="n">location</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"location"</span><span class="p">)</span> +</span><span id="Redshift.Generator.alterset_sql-408"><a href="#Redshift.Generator.alterset_sql-408"><span class="linenos">408</span></a> <span class="n">location</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LOCATION </span><span class="si">{</span><span class="n">location</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">location</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Redshift.Generator.alterset_sql-409"><a href="#Redshift.Generator.alterset_sql-409"><span class="linenos">409</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"file_format"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Redshift.Generator.alterset_sql-410"><a href="#Redshift.Generator.alterset_sql-410"><span class="linenos">410</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FILE FORMAT </span><span class="si">{</span><span class="n">file_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">file_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Redshift.Generator.alterset_sql-411"><a href="#Redshift.Generator.alterset_sql-411"><span class="linenos">411</span></a> +</span><span id="Redshift.Generator.alterset_sql-412"><a href="#Redshift.Generator.alterset_sql-412"><span class="linenos">412</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">exprs</span><span class="si">}{</span><span class="n">location</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}</span><span class="s2">"</span> +</span></pre></div> + + + + + </div> <div id="Redshift.Generator.SELECT_KINDS" class="classattr"> <div class="attr variable"> <span class="name">SELECT_KINDS</span><span class="annotation">: Tuple[str, ...]</span> = @@ -2624,6 +2668,7 @@ without precision we convert it to <code>VARCHAR(max)</code> and if it does have <dd id="Redshift.Generator.properties_sql" class="function"><a href="../generator.html#Generator.properties_sql">properties_sql</a></dd> <dd id="Redshift.Generator.root_properties" class="function"><a href="../generator.html#Generator.root_properties">root_properties</a></dd> <dd id="Redshift.Generator.properties" class="function"><a href="../generator.html#Generator.properties">properties</a></dd> + <dd id="Redshift.Generator.with_properties" class="function"><a href="../generator.html#Generator.with_properties">with_properties</a></dd> <dd id="Redshift.Generator.locate_properties" class="function"><a href="../generator.html#Generator.locate_properties">locate_properties</a></dd> <dd id="Redshift.Generator.property_name" class="function"><a href="../generator.html#Generator.property_name">property_name</a></dd> <dd id="Redshift.Generator.property_sql" class="function"><a href="../generator.html#Generator.property_sql">property_sql</a></dd> @@ -2877,6 +2922,7 @@ without precision we convert it to <code>VARCHAR(max)</code> and if it does have <dd id="Redshift.Generator.credentials_sql" class="function"><a href="../generator.html#Generator.credentials_sql">credentials_sql</a></dd> <dd id="Redshift.Generator.copy_sql" class="function"><a href="../generator.html#Generator.copy_sql">copy_sql</a></dd> <dd id="Redshift.Generator.semicolon_sql" class="function"><a href="../generator.html#Generator.semicolon_sql">semicolon_sql</a></dd> + <dd id="Redshift.Generator.datadeletionproperty_sql" class="function"><a href="../generator.html#Generator.datadeletionproperty_sql">datadeletionproperty_sql</a></dd> </div> <div><dt><a href="postgres.html#Postgres.Generator">sqlglot.dialects.postgres.Postgres.Generator</a></dt> |