summaryrefslogtreecommitdiffstats
path: root/docs/sqlglot/dialects/redshift.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/sqlglot/dialects/redshift.html')
-rw-r--r--docs/sqlglot/dialects/redshift.html1086
1 files changed, 577 insertions, 509 deletions
diff --git a/docs/sqlglot/dialects/redshift.html b/docs/sqlglot/dialects/redshift.html
index dfee18f..4224fdb 100644
--- a/docs/sqlglot/dialects/redshift.html
+++ b/docs/sqlglot/dialects/redshift.html
@@ -57,6 +57,9 @@
<li>
<a class="function" href="#Redshift.Generator.datatype_sql">datatype_sql</a>
</li>
+ <li>
+ <a class="function" href="#Redshift.Generator.can_identify">can_identify</a>
+ </li>
</ul>
</li>
@@ -102,167 +105,170 @@
</span><span id="L-14"><a href="#L-14"><span class="linenos"> 14</span></a>
</span><span id="L-15"><a href="#L-15"><span class="linenos"> 15</span></a>
</span><span id="L-16"><a href="#L-16"><span class="linenos"> 16</span></a><span class="k">class</span> <span class="nc">Redshift</span><span class="p">(</span><span class="n">Postgres</span><span class="p">):</span>
-</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">&quot;&#39;YYYY-MM-DD HH:MI:SS&#39;&quot;</span>
-</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span>
-</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a> <span class="s2">&quot;MON&quot;</span><span class="p">:</span> <span class="s2">&quot;%b&quot;</span><span class="p">,</span>
-</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a> <span class="s2">&quot;HH&quot;</span><span class="p">:</span> <span class="s2">&quot;%H&quot;</span><span class="p">,</span>
-</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> <span class="p">}</span>
-</span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a>
-</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span>
-</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span>
-</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span>
-</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
-</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
-</span><span id="L-30"><a href="#L-30"><span class="linenos"> 30</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
-</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> <span class="p">),</span>
-</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span>
-</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
-</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span>
-</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
-</span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="p">),</span>
-</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> <span class="s2">&quot;NVL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
-</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> <span class="s2">&quot;STRTOL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
-</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a> <span class="p">}</span>
-</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a>
-</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span>
-</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a>
-</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span>
-</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
-</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a> <span class="p">)</span> <span class="o">-&gt;</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span>
-</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span>
-</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a>
-</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a> <span class="k">if</span> <span class="p">(</span>
-</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span>
-</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;varchar&quot;</span><span class="p">)</span>
-</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span>
-</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)</span>
-</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> <span class="p">):</span>
-</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">,</span> <span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)])</span>
-</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a>
-</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="k">return</span> <span class="n">this</span>
-</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a>
-</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span>
-</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">]</span>
-</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a>
-</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span>
-</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="s2">&quot;HLLSKETCH&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span>
-</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="s2">&quot;SUPER&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span>
-</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span>
-</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="s2">&quot;TIME&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span>
-</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="s2">&quot;TIMETZ&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span>
-</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="s2">&quot;TOP&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span>
-</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> <span class="s2">&quot;UNLOAD&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span>
-</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span>
-</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="p">}</span>
-</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a>
-</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span>
-</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
-</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;#&quot;</span><span class="p">)</span>
-</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a>
-</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span>
-</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span>
-</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span>
-</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a>
-</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span>
-</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
-</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
-</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">&quot;INTEGER&quot;</span><span class="p">,</span>
-</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="p">}</span>
-</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a>
-</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span>
-</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span>
-</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="p">}</span>
-</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a>
-</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span>
-</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
-</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">,</span>
-</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
-</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
-</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="p">),</span>
-</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
-</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
+</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="c1"># https://docs.aws.amazon.com/redshift/latest/dg/r_names.html</span>
+</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span>
+</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a>
+</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">&quot;&#39;YYYY-MM-DD HH:MI:SS&#39;&quot;</span>
+</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span>
+</span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a> <span class="s2">&quot;MON&quot;</span><span class="p">:</span> <span class="s2">&quot;%b&quot;</span><span class="p">,</span>
+</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> <span class="s2">&quot;HH&quot;</span><span class="p">:</span> <span class="s2">&quot;%H&quot;</span><span class="p">,</span>
+</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a> <span class="p">}</span>
+</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a>
+</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span>
+</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span>
+</span><span id="L-30"><a href="#L-30"><span class="linenos"> 30</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span>
+</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
+</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
+</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
+</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="p">),</span>
+</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span>
+</span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
+</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span>
+</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
+</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a> <span class="p">),</span>
+</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a> <span class="s2">&quot;NVL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
+</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="s2">&quot;STRTOL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
+</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> <span class="p">}</span>
+</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a>
+</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span>
+</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a>
+</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span>
+</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
+</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a> <span class="p">)</span> <span class="o">-&gt;</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span>
+</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span>
+</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a>
+</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> <span class="k">if</span> <span class="p">(</span>
+</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span>
+</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;varchar&quot;</span><span class="p">)</span>
+</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span>
+</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)</span>
+</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="p">):</span>
+</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">,</span> <span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)])</span>
+</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a>
+</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="k">return</span> <span class="n">this</span>
+</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a>
+</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span>
+</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">]</span>
+</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a>
+</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span>
+</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="s2">&quot;HLLSKETCH&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span>
+</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="s2">&quot;SUPER&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span>
+</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span>
+</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> <span class="s2">&quot;TIME&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span>
+</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="s2">&quot;TIMETZ&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span>
+</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="s2">&quot;TOP&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span>
+</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="s2">&quot;UNLOAD&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span>
+</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span>
+</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="p">}</span>
+</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a>
+</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span>
+</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
+</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;#&quot;</span><span class="p">)</span>
+</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a>
+</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span>
+</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span>
+</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span>
+</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a>
+</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span>
+</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
+</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
+</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">&quot;INTEGER&quot;</span><span class="p">,</span>
+</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="p">}</span>
+</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a>
+</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span>
+</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span>
+</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="p">}</span>
+</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a>
+</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span>
+</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
+</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">,</span>
+</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
+</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a> <span class="p">),</span>
-</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)&quot;</span><span class="p">,</span>
-</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span>
-</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">&quot;STRTOL&quot;</span><span class="p">),</span>
-</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
-</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
-</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
-</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]),</span>
-</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="s1">&#39;COMPOUND &#39;</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">&#39;compound&#39;</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">&#39;&#39;</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">)&quot;</span><span class="p">,</span>
-</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span>
-</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="p">}</span>
-</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a>
-</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span>
-</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span>
+</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
+</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
+</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="p">),</span>
+</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)&quot;</span><span class="p">,</span>
+</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span>
+</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">&quot;STRTOL&quot;</span><span class="p">),</span>
+</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
+</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
+</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
+</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]),</span>
+</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="s1">&#39;COMPOUND &#39;</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">&#39;compound&#39;</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">&#39;&#39;</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">)&quot;</span><span class="p">,</span>
+</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span>
+</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="p">}</span>
</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a>
-</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span>
-</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span>
+</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span>
+</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span>
</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a>
-</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">&quot;snapshot&quot;</span><span class="p">,</span> <span class="s2">&quot;type&quot;</span><span class="p">}</span>
-</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a>
-</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
-</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span>
-</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a>
-</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span>
-</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span>
-</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a><span class="sd"> very slow.</span>
-</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a><span class="sd"> &quot;&quot;&quot;</span>
-</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a>
-</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span>
-</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span>
-</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
-</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a>
-</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;alias&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span>
-</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a>
-</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span>
+</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span>
+</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span>
+</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a>
+</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">&quot;snapshot&quot;</span><span class="p">,</span> <span class="s2">&quot;type&quot;</span><span class="p">}</span>
+</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a>
+</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
+</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span>
+</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a>
+</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span>
+</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span>
+</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a><span class="sd"> very slow.</span>
+</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a><span class="sd"> &quot;&quot;&quot;</span>
+</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a>
+</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span>
+</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span>
+</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
+</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a>
+</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;alias&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span>
</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a>
-</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span>
-</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span>
-</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span>
-</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span>
-</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span>
-</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="p">]</span>
-</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a>
-</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span>
-</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a>
-</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
-</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
-</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
-</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
-</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a>
-</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span>
-</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a>
-</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;Redshift doesn&#39;t have `WITH` as part of their with_properties so we remove it&quot;&quot;&quot;</span>
-</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
-</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a>
-</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
-</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span>
-</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span>
-</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span>
-</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span>
-</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a><span class="sd"> &quot;&quot;&quot;</span>
-</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;text&quot;</span><span class="p">):</span>
-</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
-</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;this&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span>
-</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">)</span>
-</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a>
-</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span>
-</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</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">&quot;MAX&quot;</span><span class="p">))</span>
+</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span>
+</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a>
+</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span>
+</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span>
+</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span>
+</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span>
+</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span>
+</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="p">]</span>
+</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a>
+</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span>
+</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a>
+</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
+</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
+</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
+</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a>
+</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span>
+</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a>
+</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;Redshift doesn&#39;t have `WITH` as part of their with_properties so we remove it&quot;&quot;&quot;</span>
+</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
+</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a>
+</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
+</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span>
+</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span>
+</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span>
+</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span>
+</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a><span class="sd"> &quot;&quot;&quot;</span>
+</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;text&quot;</span><span class="p">):</span>
+</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
+</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;this&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span>
+</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">)</span>
</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a>
-</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
+</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span>
+</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</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">&quot;MAX&quot;</span><span class="p">))</span>
+</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a>
+</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
</span></pre></div>
@@ -279,167 +285,170 @@
</div>
<a class="headerlink" href="#Redshift"></a>
<div class="pdoc-code codehilite"><pre><span></span><span id="Redshift-17"><a href="#Redshift-17"><span class="linenos"> 17</span></a><span class="k">class</span> <span class="nc">Redshift</span><span class="p">(</span><span class="n">Postgres</span><span class="p">):</span>
-</span><span id="Redshift-18"><a href="#Redshift-18"><span class="linenos"> 18</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">&quot;&#39;YYYY-MM-DD HH:MI:SS&#39;&quot;</span>
-</span><span id="Redshift-19"><a href="#Redshift-19"><span class="linenos"> 19</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift-20"><a href="#Redshift-20"><span class="linenos"> 20</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span>
-</span><span id="Redshift-21"><a href="#Redshift-21"><span class="linenos"> 21</span></a> <span class="s2">&quot;MON&quot;</span><span class="p">:</span> <span class="s2">&quot;%b&quot;</span><span class="p">,</span>
-</span><span id="Redshift-22"><a href="#Redshift-22"><span class="linenos"> 22</span></a> <span class="s2">&quot;HH&quot;</span><span class="p">:</span> <span class="s2">&quot;%H&quot;</span><span class="p">,</span>
-</span><span id="Redshift-23"><a href="#Redshift-23"><span class="linenos"> 23</span></a> <span class="p">}</span>
-</span><span id="Redshift-24"><a href="#Redshift-24"><span class="linenos"> 24</span></a>
-</span><span id="Redshift-25"><a href="#Redshift-25"><span class="linenos"> 25</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span>
-</span><span id="Redshift-26"><a href="#Redshift-26"><span class="linenos"> 26</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift-27"><a href="#Redshift-27"><span class="linenos"> 27</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span>
-</span><span id="Redshift-28"><a href="#Redshift-28"><span class="linenos"> 28</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span>
-</span><span id="Redshift-29"><a href="#Redshift-29"><span class="linenos"> 29</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
-</span><span id="Redshift-30"><a href="#Redshift-30"><span class="linenos"> 30</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
-</span><span id="Redshift-31"><a href="#Redshift-31"><span class="linenos"> 31</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
-</span><span id="Redshift-32"><a href="#Redshift-32"><span class="linenos"> 32</span></a> <span class="p">),</span>
-</span><span id="Redshift-33"><a href="#Redshift-33"><span class="linenos"> 33</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span>
-</span><span id="Redshift-34"><a href="#Redshift-34"><span class="linenos"> 34</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
-</span><span id="Redshift-35"><a href="#Redshift-35"><span class="linenos"> 35</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span>
-</span><span id="Redshift-36"><a href="#Redshift-36"><span class="linenos"> 36</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
-</span><span id="Redshift-37"><a href="#Redshift-37"><span class="linenos"> 37</span></a> <span class="p">),</span>
-</span><span id="Redshift-38"><a href="#Redshift-38"><span class="linenos"> 38</span></a> <span class="s2">&quot;NVL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
-</span><span id="Redshift-39"><a href="#Redshift-39"><span class="linenos"> 39</span></a> <span class="s2">&quot;STRTOL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
-</span><span id="Redshift-40"><a href="#Redshift-40"><span class="linenos"> 40</span></a> <span class="p">}</span>
-</span><span id="Redshift-41"><a href="#Redshift-41"><span class="linenos"> 41</span></a>
-</span><span id="Redshift-42"><a href="#Redshift-42"><span class="linenos"> 42</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span>
-</span><span id="Redshift-43"><a href="#Redshift-43"><span class="linenos"> 43</span></a>
-</span><span id="Redshift-44"><a href="#Redshift-44"><span class="linenos"> 44</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span>
-</span><span id="Redshift-45"><a href="#Redshift-45"><span class="linenos"> 45</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
-</span><span id="Redshift-46"><a href="#Redshift-46"><span class="linenos"> 46</span></a> <span class="p">)</span> <span class="o">-&gt;</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span>
-</span><span id="Redshift-47"><a href="#Redshift-47"><span class="linenos"> 47</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span>
-</span><span id="Redshift-48"><a href="#Redshift-48"><span class="linenos"> 48</span></a>
-</span><span id="Redshift-49"><a href="#Redshift-49"><span class="linenos"> 49</span></a> <span class="k">if</span> <span class="p">(</span>
-</span><span id="Redshift-50"><a href="#Redshift-50"><span class="linenos"> 50</span></a> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span>
-</span><span id="Redshift-51"><a href="#Redshift-51"><span class="linenos"> 51</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;varchar&quot;</span><span class="p">)</span>
-</span><span id="Redshift-52"><a href="#Redshift-52"><span class="linenos"> 52</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span>
-</span><span id="Redshift-53"><a href="#Redshift-53"><span class="linenos"> 53</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)</span>
-</span><span id="Redshift-54"><a href="#Redshift-54"><span class="linenos"> 54</span></a> <span class="p">):</span>
-</span><span id="Redshift-55"><a href="#Redshift-55"><span class="linenos"> 55</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">,</span> <span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)])</span>
-</span><span id="Redshift-56"><a href="#Redshift-56"><span class="linenos"> 56</span></a>
-</span><span id="Redshift-57"><a href="#Redshift-57"><span class="linenos"> 57</span></a> <span class="k">return</span> <span class="n">this</span>
-</span><span id="Redshift-58"><a href="#Redshift-58"><span class="linenos"> 58</span></a>
-</span><span id="Redshift-59"><a href="#Redshift-59"><span class="linenos"> 59</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span>
-</span><span id="Redshift-60"><a href="#Redshift-60"><span class="linenos"> 60</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="Redshift-61"><a href="#Redshift-61"><span class="linenos"> 61</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="Redshift-62"><a href="#Redshift-62"><span class="linenos"> 62</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">]</span>
-</span><span id="Redshift-63"><a href="#Redshift-63"><span class="linenos"> 63</span></a>
-</span><span id="Redshift-64"><a href="#Redshift-64"><span class="linenos"> 64</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift-65"><a href="#Redshift-65"><span class="linenos"> 65</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span>
-</span><span id="Redshift-66"><a href="#Redshift-66"><span class="linenos"> 66</span></a> <span class="s2">&quot;HLLSKETCH&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span>
-</span><span id="Redshift-67"><a href="#Redshift-67"><span class="linenos"> 67</span></a> <span class="s2">&quot;SUPER&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span>
-</span><span id="Redshift-68"><a href="#Redshift-68"><span class="linenos"> 68</span></a> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span>
-</span><span id="Redshift-69"><a href="#Redshift-69"><span class="linenos"> 69</span></a> <span class="s2">&quot;TIME&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span>
-</span><span id="Redshift-70"><a href="#Redshift-70"><span class="linenos"> 70</span></a> <span class="s2">&quot;TIMETZ&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span>
-</span><span id="Redshift-71"><a href="#Redshift-71"><span class="linenos"> 71</span></a> <span class="s2">&quot;TOP&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span>
-</span><span id="Redshift-72"><a href="#Redshift-72"><span class="linenos"> 72</span></a> <span class="s2">&quot;UNLOAD&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span>
-</span><span id="Redshift-73"><a href="#Redshift-73"><span class="linenos"> 73</span></a> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span>
-</span><span id="Redshift-74"><a href="#Redshift-74"><span class="linenos"> 74</span></a> <span class="p">}</span>
-</span><span id="Redshift-75"><a href="#Redshift-75"><span class="linenos"> 75</span></a>
-</span><span id="Redshift-76"><a href="#Redshift-76"><span class="linenos"> 76</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span>
-</span><span id="Redshift-77"><a href="#Redshift-77"><span class="linenos"> 77</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
-</span><span id="Redshift-78"><a href="#Redshift-78"><span class="linenos"> 78</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;#&quot;</span><span class="p">)</span>
-</span><span id="Redshift-79"><a href="#Redshift-79"><span class="linenos"> 79</span></a>
-</span><span id="Redshift-80"><a href="#Redshift-80"><span class="linenos"> 80</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span>
-</span><span id="Redshift-81"><a href="#Redshift-81"><span class="linenos"> 81</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span>
-</span><span id="Redshift-82"><a href="#Redshift-82"><span class="linenos"> 82</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span>
-</span><span id="Redshift-83"><a href="#Redshift-83"><span class="linenos"> 83</span></a>
-</span><span id="Redshift-84"><a href="#Redshift-84"><span class="linenos"> 84</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift-85"><a href="#Redshift-85"><span class="linenos"> 85</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span>
-</span><span id="Redshift-86"><a href="#Redshift-86"><span class="linenos"> 86</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
-</span><span id="Redshift-87"><a href="#Redshift-87"><span class="linenos"> 87</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
-</span><span id="Redshift-88"><a href="#Redshift-88"><span class="linenos"> 88</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">&quot;INTEGER&quot;</span><span class="p">,</span>
-</span><span id="Redshift-89"><a href="#Redshift-89"><span class="linenos"> 89</span></a> <span class="p">}</span>
-</span><span id="Redshift-90"><a href="#Redshift-90"><span class="linenos"> 90</span></a>
-</span><span id="Redshift-91"><a href="#Redshift-91"><span class="linenos"> 91</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift-92"><a href="#Redshift-92"><span class="linenos"> 92</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span>
-</span><span id="Redshift-93"><a href="#Redshift-93"><span class="linenos"> 93</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span>
-</span><span id="Redshift-94"><a href="#Redshift-94"><span class="linenos"> 94</span></a> <span class="p">}</span>
-</span><span id="Redshift-95"><a href="#Redshift-95"><span class="linenos"> 95</span></a>
-</span><span id="Redshift-96"><a href="#Redshift-96"><span class="linenos"> 96</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift-97"><a href="#Redshift-97"><span class="linenos"> 97</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span>
-</span><span id="Redshift-98"><a href="#Redshift-98"><span class="linenos"> 98</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
-</span><span id="Redshift-99"><a href="#Redshift-99"><span class="linenos"> 99</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">,</span>
-</span><span id="Redshift-100"><a href="#Redshift-100"><span class="linenos">100</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
-</span><span id="Redshift-101"><a href="#Redshift-101"><span class="linenos">101</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
-</span><span id="Redshift-102"><a href="#Redshift-102"><span class="linenos">102</span></a> <span class="p">),</span>
-</span><span id="Redshift-103"><a href="#Redshift-103"><span class="linenos">103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
-</span><span id="Redshift-104"><a href="#Redshift-104"><span class="linenos">104</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
+</span><span id="Redshift-18"><a href="#Redshift-18"><span class="linenos"> 18</span></a> <span class="c1"># https://docs.aws.amazon.com/redshift/latest/dg/r_names.html</span>
+</span><span id="Redshift-19"><a href="#Redshift-19"><span class="linenos"> 19</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span>
+</span><span id="Redshift-20"><a href="#Redshift-20"><span class="linenos"> 20</span></a>
+</span><span id="Redshift-21"><a href="#Redshift-21"><span class="linenos"> 21</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">&quot;&#39;YYYY-MM-DD HH:MI:SS&#39;&quot;</span>
+</span><span id="Redshift-22"><a href="#Redshift-22"><span class="linenos"> 22</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift-23"><a href="#Redshift-23"><span class="linenos"> 23</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span>
+</span><span id="Redshift-24"><a href="#Redshift-24"><span class="linenos"> 24</span></a> <span class="s2">&quot;MON&quot;</span><span class="p">:</span> <span class="s2">&quot;%b&quot;</span><span class="p">,</span>
+</span><span id="Redshift-25"><a href="#Redshift-25"><span class="linenos"> 25</span></a> <span class="s2">&quot;HH&quot;</span><span class="p">:</span> <span class="s2">&quot;%H&quot;</span><span class="p">,</span>
+</span><span id="Redshift-26"><a href="#Redshift-26"><span class="linenos"> 26</span></a> <span class="p">}</span>
+</span><span id="Redshift-27"><a href="#Redshift-27"><span class="linenos"> 27</span></a>
+</span><span id="Redshift-28"><a href="#Redshift-28"><span class="linenos"> 28</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span>
+</span><span id="Redshift-29"><a href="#Redshift-29"><span class="linenos"> 29</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift-30"><a href="#Redshift-30"><span class="linenos"> 30</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span>
+</span><span id="Redshift-31"><a href="#Redshift-31"><span class="linenos"> 31</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span>
+</span><span id="Redshift-32"><a href="#Redshift-32"><span class="linenos"> 32</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
+</span><span id="Redshift-33"><a href="#Redshift-33"><span class="linenos"> 33</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
+</span><span id="Redshift-34"><a href="#Redshift-34"><span class="linenos"> 34</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
+</span><span id="Redshift-35"><a href="#Redshift-35"><span class="linenos"> 35</span></a> <span class="p">),</span>
+</span><span id="Redshift-36"><a href="#Redshift-36"><span class="linenos"> 36</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span>
+</span><span id="Redshift-37"><a href="#Redshift-37"><span class="linenos"> 37</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
+</span><span id="Redshift-38"><a href="#Redshift-38"><span class="linenos"> 38</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span>
+</span><span id="Redshift-39"><a href="#Redshift-39"><span class="linenos"> 39</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
+</span><span id="Redshift-40"><a href="#Redshift-40"><span class="linenos"> 40</span></a> <span class="p">),</span>
+</span><span id="Redshift-41"><a href="#Redshift-41"><span class="linenos"> 41</span></a> <span class="s2">&quot;NVL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
+</span><span id="Redshift-42"><a href="#Redshift-42"><span class="linenos"> 42</span></a> <span class="s2">&quot;STRTOL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
+</span><span id="Redshift-43"><a href="#Redshift-43"><span class="linenos"> 43</span></a> <span class="p">}</span>
+</span><span id="Redshift-44"><a href="#Redshift-44"><span class="linenos"> 44</span></a>
+</span><span id="Redshift-45"><a href="#Redshift-45"><span class="linenos"> 45</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span>
+</span><span id="Redshift-46"><a href="#Redshift-46"><span class="linenos"> 46</span></a>
+</span><span id="Redshift-47"><a href="#Redshift-47"><span class="linenos"> 47</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span>
+</span><span id="Redshift-48"><a href="#Redshift-48"><span class="linenos"> 48</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
+</span><span id="Redshift-49"><a href="#Redshift-49"><span class="linenos"> 49</span></a> <span class="p">)</span> <span class="o">-&gt;</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span>
+</span><span id="Redshift-50"><a href="#Redshift-50"><span class="linenos"> 50</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span>
+</span><span id="Redshift-51"><a href="#Redshift-51"><span class="linenos"> 51</span></a>
+</span><span id="Redshift-52"><a href="#Redshift-52"><span class="linenos"> 52</span></a> <span class="k">if</span> <span class="p">(</span>
+</span><span id="Redshift-53"><a href="#Redshift-53"><span class="linenos"> 53</span></a> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span>
+</span><span id="Redshift-54"><a href="#Redshift-54"><span class="linenos"> 54</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;varchar&quot;</span><span class="p">)</span>
+</span><span id="Redshift-55"><a href="#Redshift-55"><span class="linenos"> 55</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span>
+</span><span id="Redshift-56"><a href="#Redshift-56"><span class="linenos"> 56</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)</span>
+</span><span id="Redshift-57"><a href="#Redshift-57"><span class="linenos"> 57</span></a> <span class="p">):</span>
+</span><span id="Redshift-58"><a href="#Redshift-58"><span class="linenos"> 58</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">,</span> <span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)])</span>
+</span><span id="Redshift-59"><a href="#Redshift-59"><span class="linenos"> 59</span></a>
+</span><span id="Redshift-60"><a href="#Redshift-60"><span class="linenos"> 60</span></a> <span class="k">return</span> <span class="n">this</span>
+</span><span id="Redshift-61"><a href="#Redshift-61"><span class="linenos"> 61</span></a>
+</span><span id="Redshift-62"><a href="#Redshift-62"><span class="linenos"> 62</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span>
+</span><span id="Redshift-63"><a href="#Redshift-63"><span class="linenos"> 63</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="Redshift-64"><a href="#Redshift-64"><span class="linenos"> 64</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="Redshift-65"><a href="#Redshift-65"><span class="linenos"> 65</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">]</span>
+</span><span id="Redshift-66"><a href="#Redshift-66"><span class="linenos"> 66</span></a>
+</span><span id="Redshift-67"><a href="#Redshift-67"><span class="linenos"> 67</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift-68"><a href="#Redshift-68"><span class="linenos"> 68</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span>
+</span><span id="Redshift-69"><a href="#Redshift-69"><span class="linenos"> 69</span></a> <span class="s2">&quot;HLLSKETCH&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span>
+</span><span id="Redshift-70"><a href="#Redshift-70"><span class="linenos"> 70</span></a> <span class="s2">&quot;SUPER&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span>
+</span><span id="Redshift-71"><a href="#Redshift-71"><span class="linenos"> 71</span></a> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span>
+</span><span id="Redshift-72"><a href="#Redshift-72"><span class="linenos"> 72</span></a> <span class="s2">&quot;TIME&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span>
+</span><span id="Redshift-73"><a href="#Redshift-73"><span class="linenos"> 73</span></a> <span class="s2">&quot;TIMETZ&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span>
+</span><span id="Redshift-74"><a href="#Redshift-74"><span class="linenos"> 74</span></a> <span class="s2">&quot;TOP&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span>
+</span><span id="Redshift-75"><a href="#Redshift-75"><span class="linenos"> 75</span></a> <span class="s2">&quot;UNLOAD&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span>
+</span><span id="Redshift-76"><a href="#Redshift-76"><span class="linenos"> 76</span></a> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span>
+</span><span id="Redshift-77"><a href="#Redshift-77"><span class="linenos"> 77</span></a> <span class="p">}</span>
+</span><span id="Redshift-78"><a href="#Redshift-78"><span class="linenos"> 78</span></a>
+</span><span id="Redshift-79"><a href="#Redshift-79"><span class="linenos"> 79</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span>
+</span><span id="Redshift-80"><a href="#Redshift-80"><span class="linenos"> 80</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
+</span><span id="Redshift-81"><a href="#Redshift-81"><span class="linenos"> 81</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;#&quot;</span><span class="p">)</span>
+</span><span id="Redshift-82"><a href="#Redshift-82"><span class="linenos"> 82</span></a>
+</span><span id="Redshift-83"><a href="#Redshift-83"><span class="linenos"> 83</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span>
+</span><span id="Redshift-84"><a href="#Redshift-84"><span class="linenos"> 84</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span>
+</span><span id="Redshift-85"><a href="#Redshift-85"><span class="linenos"> 85</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span>
+</span><span id="Redshift-86"><a href="#Redshift-86"><span class="linenos"> 86</span></a>
+</span><span id="Redshift-87"><a href="#Redshift-87"><span class="linenos"> 87</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift-88"><a href="#Redshift-88"><span class="linenos"> 88</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span>
+</span><span id="Redshift-89"><a href="#Redshift-89"><span class="linenos"> 89</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
+</span><span id="Redshift-90"><a href="#Redshift-90"><span class="linenos"> 90</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
+</span><span id="Redshift-91"><a href="#Redshift-91"><span class="linenos"> 91</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">&quot;INTEGER&quot;</span><span class="p">,</span>
+</span><span id="Redshift-92"><a href="#Redshift-92"><span class="linenos"> 92</span></a> <span class="p">}</span>
+</span><span id="Redshift-93"><a href="#Redshift-93"><span class="linenos"> 93</span></a>
+</span><span id="Redshift-94"><a href="#Redshift-94"><span class="linenos"> 94</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift-95"><a href="#Redshift-95"><span class="linenos"> 95</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span>
+</span><span id="Redshift-96"><a href="#Redshift-96"><span class="linenos"> 96</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span>
+</span><span id="Redshift-97"><a href="#Redshift-97"><span class="linenos"> 97</span></a> <span class="p">}</span>
+</span><span id="Redshift-98"><a href="#Redshift-98"><span class="linenos"> 98</span></a>
+</span><span id="Redshift-99"><a href="#Redshift-99"><span class="linenos"> 99</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift-100"><a href="#Redshift-100"><span class="linenos">100</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span>
+</span><span id="Redshift-101"><a href="#Redshift-101"><span class="linenos">101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
+</span><span id="Redshift-102"><a href="#Redshift-102"><span class="linenos">102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">,</span>
+</span><span id="Redshift-103"><a href="#Redshift-103"><span class="linenos">103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
+</span><span id="Redshift-104"><a href="#Redshift-104"><span class="linenos">104</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
</span><span id="Redshift-105"><a href="#Redshift-105"><span class="linenos">105</span></a> <span class="p">),</span>
-</span><span id="Redshift-106"><a href="#Redshift-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)&quot;</span><span class="p">,</span>
-</span><span id="Redshift-107"><a href="#Redshift-107"><span class="linenos">107</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span>
-</span><span id="Redshift-108"><a href="#Redshift-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">&quot;STRTOL&quot;</span><span class="p">),</span>
-</span><span id="Redshift-109"><a href="#Redshift-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
-</span><span id="Redshift-110"><a href="#Redshift-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
-</span><span id="Redshift-111"><a href="#Redshift-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
-</span><span id="Redshift-112"><a href="#Redshift-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]),</span>
-</span><span id="Redshift-113"><a href="#Redshift-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="s1">&#39;COMPOUND &#39;</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">&#39;compound&#39;</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">&#39;&#39;</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">)&quot;</span><span class="p">,</span>
-</span><span id="Redshift-114"><a href="#Redshift-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span>
-</span><span id="Redshift-115"><a href="#Redshift-115"><span class="linenos">115</span></a> <span class="p">}</span>
-</span><span id="Redshift-116"><a href="#Redshift-116"><span class="linenos">116</span></a>
-</span><span id="Redshift-117"><a href="#Redshift-117"><span class="linenos">117</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span>
-</span><span id="Redshift-118"><a href="#Redshift-118"><span class="linenos">118</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span>
+</span><span id="Redshift-106"><a href="#Redshift-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
+</span><span id="Redshift-107"><a href="#Redshift-107"><span class="linenos">107</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
+</span><span id="Redshift-108"><a href="#Redshift-108"><span class="linenos">108</span></a> <span class="p">),</span>
+</span><span id="Redshift-109"><a href="#Redshift-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)&quot;</span><span class="p">,</span>
+</span><span id="Redshift-110"><a href="#Redshift-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span>
+</span><span id="Redshift-111"><a href="#Redshift-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">&quot;STRTOL&quot;</span><span class="p">),</span>
+</span><span id="Redshift-112"><a href="#Redshift-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
+</span><span id="Redshift-113"><a href="#Redshift-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
+</span><span id="Redshift-114"><a href="#Redshift-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
+</span><span id="Redshift-115"><a href="#Redshift-115"><span class="linenos">115</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]),</span>
+</span><span id="Redshift-116"><a href="#Redshift-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="s1">&#39;COMPOUND &#39;</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">&#39;compound&#39;</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">&#39;&#39;</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">)&quot;</span><span class="p">,</span>
+</span><span id="Redshift-117"><a href="#Redshift-117"><span class="linenos">117</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span>
+</span><span id="Redshift-118"><a href="#Redshift-118"><span class="linenos">118</span></a> <span class="p">}</span>
</span><span id="Redshift-119"><a href="#Redshift-119"><span class="linenos">119</span></a>
-</span><span id="Redshift-120"><a href="#Redshift-120"><span class="linenos">120</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span>
-</span><span id="Redshift-121"><a href="#Redshift-121"><span class="linenos">121</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span>
+</span><span id="Redshift-120"><a href="#Redshift-120"><span class="linenos">120</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span>
+</span><span id="Redshift-121"><a href="#Redshift-121"><span class="linenos">121</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span>
</span><span id="Redshift-122"><a href="#Redshift-122"><span class="linenos">122</span></a>
-</span><span id="Redshift-123"><a href="#Redshift-123"><span class="linenos">123</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">&quot;snapshot&quot;</span><span class="p">,</span> <span class="s2">&quot;type&quot;</span><span class="p">}</span>
-</span><span id="Redshift-124"><a href="#Redshift-124"><span class="linenos">124</span></a>
-</span><span id="Redshift-125"><a href="#Redshift-125"><span class="linenos">125</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="Redshift-126"><a href="#Redshift-126"><span class="linenos">126</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
-</span><span id="Redshift-127"><a href="#Redshift-127"><span class="linenos">127</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span>
-</span><span id="Redshift-128"><a href="#Redshift-128"><span class="linenos">128</span></a>
-</span><span id="Redshift-129"><a href="#Redshift-129"><span class="linenos">129</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span>
-</span><span id="Redshift-130"><a href="#Redshift-130"><span class="linenos">130</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span>
-</span><span id="Redshift-131"><a href="#Redshift-131"><span class="linenos">131</span></a><span class="sd"> very slow.</span>
-</span><span id="Redshift-132"><a href="#Redshift-132"><span class="linenos">132</span></a><span class="sd"> &quot;&quot;&quot;</span>
-</span><span id="Redshift-133"><a href="#Redshift-133"><span class="linenos">133</span></a>
-</span><span id="Redshift-134"><a href="#Redshift-134"><span class="linenos">134</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span>
-</span><span id="Redshift-135"><a href="#Redshift-135"><span class="linenos">135</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span>
-</span><span id="Redshift-136"><a href="#Redshift-136"><span class="linenos">136</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
-</span><span id="Redshift-137"><a href="#Redshift-137"><span class="linenos">137</span></a>
-</span><span id="Redshift-138"><a href="#Redshift-138"><span class="linenos">138</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;alias&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span>
-</span><span id="Redshift-139"><a href="#Redshift-139"><span class="linenos">139</span></a>
-</span><span id="Redshift-140"><a href="#Redshift-140"><span class="linenos">140</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="Redshift-141"><a href="#Redshift-141"><span class="linenos">141</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span>
+</span><span id="Redshift-123"><a href="#Redshift-123"><span class="linenos">123</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span>
+</span><span id="Redshift-124"><a href="#Redshift-124"><span class="linenos">124</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span>
+</span><span id="Redshift-125"><a href="#Redshift-125"><span class="linenos">125</span></a>
+</span><span id="Redshift-126"><a href="#Redshift-126"><span class="linenos">126</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">&quot;snapshot&quot;</span><span class="p">,</span> <span class="s2">&quot;type&quot;</span><span class="p">}</span>
+</span><span id="Redshift-127"><a href="#Redshift-127"><span class="linenos">127</span></a>
+</span><span id="Redshift-128"><a href="#Redshift-128"><span class="linenos">128</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="Redshift-129"><a href="#Redshift-129"><span class="linenos">129</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
+</span><span id="Redshift-130"><a href="#Redshift-130"><span class="linenos">130</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span>
+</span><span id="Redshift-131"><a href="#Redshift-131"><span class="linenos">131</span></a>
+</span><span id="Redshift-132"><a href="#Redshift-132"><span class="linenos">132</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span>
+</span><span id="Redshift-133"><a href="#Redshift-133"><span class="linenos">133</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span>
+</span><span id="Redshift-134"><a href="#Redshift-134"><span class="linenos">134</span></a><span class="sd"> very slow.</span>
+</span><span id="Redshift-135"><a href="#Redshift-135"><span class="linenos">135</span></a><span class="sd"> &quot;&quot;&quot;</span>
+</span><span id="Redshift-136"><a href="#Redshift-136"><span class="linenos">136</span></a>
+</span><span id="Redshift-137"><a href="#Redshift-137"><span class="linenos">137</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span>
+</span><span id="Redshift-138"><a href="#Redshift-138"><span class="linenos">138</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span>
+</span><span id="Redshift-139"><a href="#Redshift-139"><span class="linenos">139</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
+</span><span id="Redshift-140"><a href="#Redshift-140"><span class="linenos">140</span></a>
+</span><span id="Redshift-141"><a href="#Redshift-141"><span class="linenos">141</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;alias&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span>
</span><span id="Redshift-142"><a href="#Redshift-142"><span class="linenos">142</span></a>
-</span><span id="Redshift-143"><a href="#Redshift-143"><span class="linenos">143</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span>
-</span><span id="Redshift-144"><a href="#Redshift-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span>
-</span><span id="Redshift-145"><a href="#Redshift-145"><span class="linenos">145</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span>
-</span><span id="Redshift-146"><a href="#Redshift-146"><span class="linenos">146</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span>
-</span><span id="Redshift-147"><a href="#Redshift-147"><span class="linenos">147</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span>
-</span><span id="Redshift-148"><a href="#Redshift-148"><span class="linenos">148</span></a> <span class="p">]</span>
-</span><span id="Redshift-149"><a href="#Redshift-149"><span class="linenos">149</span></a>
-</span><span id="Redshift-150"><a href="#Redshift-150"><span class="linenos">150</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span>
-</span><span id="Redshift-151"><a href="#Redshift-151"><span class="linenos">151</span></a>
-</span><span id="Redshift-152"><a href="#Redshift-152"><span class="linenos">152</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
-</span><span id="Redshift-153"><a href="#Redshift-153"><span class="linenos">153</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
-</span><span id="Redshift-154"><a href="#Redshift-154"><span class="linenos">154</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
-</span><span id="Redshift-155"><a href="#Redshift-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
-</span><span id="Redshift-156"><a href="#Redshift-156"><span class="linenos">156</span></a>
-</span><span id="Redshift-157"><a href="#Redshift-157"><span class="linenos">157</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span>
-</span><span id="Redshift-158"><a href="#Redshift-158"><span class="linenos">158</span></a>
-</span><span id="Redshift-159"><a href="#Redshift-159"><span class="linenos">159</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="Redshift-160"><a href="#Redshift-160"><span class="linenos">160</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;Redshift doesn&#39;t have `WITH` as part of their with_properties so we remove it&quot;&quot;&quot;</span>
-</span><span id="Redshift-161"><a href="#Redshift-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
-</span><span id="Redshift-162"><a href="#Redshift-162"><span class="linenos">162</span></a>
-</span><span id="Redshift-163"><a href="#Redshift-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="Redshift-164"><a href="#Redshift-164"><span class="linenos">164</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
-</span><span id="Redshift-165"><a href="#Redshift-165"><span class="linenos">165</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span>
-</span><span id="Redshift-166"><a href="#Redshift-166"><span class="linenos">166</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span>
-</span><span id="Redshift-167"><a href="#Redshift-167"><span class="linenos">167</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span>
-</span><span id="Redshift-168"><a href="#Redshift-168"><span class="linenos">168</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span>
-</span><span id="Redshift-169"><a href="#Redshift-169"><span class="linenos">169</span></a><span class="sd"> &quot;&quot;&quot;</span>
-</span><span id="Redshift-170"><a href="#Redshift-170"><span class="linenos">170</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;text&quot;</span><span class="p">):</span>
-</span><span id="Redshift-171"><a href="#Redshift-171"><span class="linenos">171</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
-</span><span id="Redshift-172"><a href="#Redshift-172"><span class="linenos">172</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;this&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span>
-</span><span id="Redshift-173"><a href="#Redshift-173"><span class="linenos">173</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">)</span>
-</span><span id="Redshift-174"><a href="#Redshift-174"><span class="linenos">174</span></a>
-</span><span id="Redshift-175"><a href="#Redshift-175"><span class="linenos">175</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span>
-</span><span id="Redshift-176"><a href="#Redshift-176"><span class="linenos">176</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</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">&quot;MAX&quot;</span><span class="p">))</span>
+</span><span id="Redshift-143"><a href="#Redshift-143"><span class="linenos">143</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="Redshift-144"><a href="#Redshift-144"><span class="linenos">144</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span>
+</span><span id="Redshift-145"><a href="#Redshift-145"><span class="linenos">145</span></a>
+</span><span id="Redshift-146"><a href="#Redshift-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span>
+</span><span id="Redshift-147"><a href="#Redshift-147"><span class="linenos">147</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span>
+</span><span id="Redshift-148"><a href="#Redshift-148"><span class="linenos">148</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span>
+</span><span id="Redshift-149"><a href="#Redshift-149"><span class="linenos">149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span>
+</span><span id="Redshift-150"><a href="#Redshift-150"><span class="linenos">150</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span>
+</span><span id="Redshift-151"><a href="#Redshift-151"><span class="linenos">151</span></a> <span class="p">]</span>
+</span><span id="Redshift-152"><a href="#Redshift-152"><span class="linenos">152</span></a>
+</span><span id="Redshift-153"><a href="#Redshift-153"><span class="linenos">153</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span>
+</span><span id="Redshift-154"><a href="#Redshift-154"><span class="linenos">154</span></a>
+</span><span id="Redshift-155"><a href="#Redshift-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+</span><span id="Redshift-156"><a href="#Redshift-156"><span class="linenos">156</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
+</span><span id="Redshift-157"><a href="#Redshift-157"><span class="linenos">157</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
+</span><span id="Redshift-158"><a href="#Redshift-158"><span class="linenos">158</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
+</span><span id="Redshift-159"><a href="#Redshift-159"><span class="linenos">159</span></a>
+</span><span id="Redshift-160"><a href="#Redshift-160"><span class="linenos">160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span>
+</span><span id="Redshift-161"><a href="#Redshift-161"><span class="linenos">161</span></a>
+</span><span id="Redshift-162"><a href="#Redshift-162"><span class="linenos">162</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="Redshift-163"><a href="#Redshift-163"><span class="linenos">163</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;Redshift doesn&#39;t have `WITH` as part of their with_properties so we remove it&quot;&quot;&quot;</span>
+</span><span id="Redshift-164"><a href="#Redshift-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
+</span><span id="Redshift-165"><a href="#Redshift-165"><span class="linenos">165</span></a>
+</span><span id="Redshift-166"><a href="#Redshift-166"><span class="linenos">166</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="Redshift-167"><a href="#Redshift-167"><span class="linenos">167</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
+</span><span id="Redshift-168"><a href="#Redshift-168"><span class="linenos">168</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span>
+</span><span id="Redshift-169"><a href="#Redshift-169"><span class="linenos">169</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span>
+</span><span id="Redshift-170"><a href="#Redshift-170"><span class="linenos">170</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span>
+</span><span id="Redshift-171"><a href="#Redshift-171"><span class="linenos">171</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span>
+</span><span id="Redshift-172"><a href="#Redshift-172"><span class="linenos">172</span></a><span class="sd"> &quot;&quot;&quot;</span>
+</span><span id="Redshift-173"><a href="#Redshift-173"><span class="linenos">173</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;text&quot;</span><span class="p">):</span>
+</span><span id="Redshift-174"><a href="#Redshift-174"><span class="linenos">174</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
+</span><span id="Redshift-175"><a href="#Redshift-175"><span class="linenos">175</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;this&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span>
+</span><span id="Redshift-176"><a href="#Redshift-176"><span class="linenos">176</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">)</span>
</span><span id="Redshift-177"><a href="#Redshift-177"><span class="linenos">177</span></a>
-</span><span id="Redshift-178"><a href="#Redshift-178"><span class="linenos">178</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
+</span><span id="Redshift-178"><a href="#Redshift-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span>
+</span><span id="Redshift-179"><a href="#Redshift-179"><span class="linenos">179</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</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">&quot;MAX&quot;</span><span class="p">))</span>
+</span><span id="Redshift-180"><a href="#Redshift-180"><span class="linenos">180</span></a>
+</span><span id="Redshift-181"><a href="#Redshift-181"><span class="linenos">181</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
</span></pre></div>
@@ -451,6 +460,10 @@
<div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt>
<dd id="Redshift.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd>
<dd id="Redshift.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd>
+ <dd id="Redshift.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd>
+ <dd id="Redshift.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd>
+ <dd id="Redshift.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd>
+ <dd id="Redshift.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd>
<dd id="Redshift.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd>
<dd id="Redshift.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd>
<dd id="Redshift.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd>
@@ -474,39 +487,39 @@
</div>
<a class="headerlink" href="#Redshift.Parser"></a>
- <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Parser-25"><a href="#Redshift.Parser-25"><span class="linenos">25</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span>
-</span><span id="Redshift.Parser-26"><a href="#Redshift.Parser-26"><span class="linenos">26</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift.Parser-27"><a href="#Redshift.Parser-27"><span class="linenos">27</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span>
-</span><span id="Redshift.Parser-28"><a href="#Redshift.Parser-28"><span class="linenos">28</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span>
-</span><span id="Redshift.Parser-29"><a href="#Redshift.Parser-29"><span class="linenos">29</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
-</span><span id="Redshift.Parser-30"><a href="#Redshift.Parser-30"><span class="linenos">30</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
-</span><span id="Redshift.Parser-31"><a href="#Redshift.Parser-31"><span class="linenos">31</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
-</span><span id="Redshift.Parser-32"><a href="#Redshift.Parser-32"><span class="linenos">32</span></a> <span class="p">),</span>
-</span><span id="Redshift.Parser-33"><a href="#Redshift.Parser-33"><span class="linenos">33</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span>
-</span><span id="Redshift.Parser-34"><a href="#Redshift.Parser-34"><span class="linenos">34</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
-</span><span id="Redshift.Parser-35"><a href="#Redshift.Parser-35"><span class="linenos">35</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span>
-</span><span id="Redshift.Parser-36"><a href="#Redshift.Parser-36"><span class="linenos">36</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
-</span><span id="Redshift.Parser-37"><a href="#Redshift.Parser-37"><span class="linenos">37</span></a> <span class="p">),</span>
-</span><span id="Redshift.Parser-38"><a href="#Redshift.Parser-38"><span class="linenos">38</span></a> <span class="s2">&quot;NVL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
-</span><span id="Redshift.Parser-39"><a href="#Redshift.Parser-39"><span class="linenos">39</span></a> <span class="s2">&quot;STRTOL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
-</span><span id="Redshift.Parser-40"><a href="#Redshift.Parser-40"><span class="linenos">40</span></a> <span class="p">}</span>
-</span><span id="Redshift.Parser-41"><a href="#Redshift.Parser-41"><span class="linenos">41</span></a>
-</span><span id="Redshift.Parser-42"><a href="#Redshift.Parser-42"><span class="linenos">42</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span>
-</span><span id="Redshift.Parser-43"><a href="#Redshift.Parser-43"><span class="linenos">43</span></a>
-</span><span id="Redshift.Parser-44"><a href="#Redshift.Parser-44"><span class="linenos">44</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span>
-</span><span id="Redshift.Parser-45"><a href="#Redshift.Parser-45"><span class="linenos">45</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
-</span><span id="Redshift.Parser-46"><a href="#Redshift.Parser-46"><span class="linenos">46</span></a> <span class="p">)</span> <span class="o">-&gt;</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span>
-</span><span id="Redshift.Parser-47"><a href="#Redshift.Parser-47"><span class="linenos">47</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span>
-</span><span id="Redshift.Parser-48"><a href="#Redshift.Parser-48"><span class="linenos">48</span></a>
-</span><span id="Redshift.Parser-49"><a href="#Redshift.Parser-49"><span class="linenos">49</span></a> <span class="k">if</span> <span class="p">(</span>
-</span><span id="Redshift.Parser-50"><a href="#Redshift.Parser-50"><span class="linenos">50</span></a> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span>
-</span><span id="Redshift.Parser-51"><a href="#Redshift.Parser-51"><span class="linenos">51</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;varchar&quot;</span><span class="p">)</span>
-</span><span id="Redshift.Parser-52"><a href="#Redshift.Parser-52"><span class="linenos">52</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span>
-</span><span id="Redshift.Parser-53"><a href="#Redshift.Parser-53"><span class="linenos">53</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)</span>
-</span><span id="Redshift.Parser-54"><a href="#Redshift.Parser-54"><span class="linenos">54</span></a> <span class="p">):</span>
-</span><span id="Redshift.Parser-55"><a href="#Redshift.Parser-55"><span class="linenos">55</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">,</span> <span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)])</span>
-</span><span id="Redshift.Parser-56"><a href="#Redshift.Parser-56"><span class="linenos">56</span></a>
-</span><span id="Redshift.Parser-57"><a href="#Redshift.Parser-57"><span class="linenos">57</span></a> <span class="k">return</span> <span class="n">this</span>
+ <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Parser-28"><a href="#Redshift.Parser-28"><span class="linenos">28</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span>
+</span><span id="Redshift.Parser-29"><a href="#Redshift.Parser-29"><span class="linenos">29</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift.Parser-30"><a href="#Redshift.Parser-30"><span class="linenos">30</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span>
+</span><span id="Redshift.Parser-31"><a href="#Redshift.Parser-31"><span class="linenos">31</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">(</span>
+</span><span id="Redshift.Parser-32"><a href="#Redshift.Parser-32"><span class="linenos">32</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
+</span><span id="Redshift.Parser-33"><a href="#Redshift.Parser-33"><span class="linenos">33</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
+</span><span id="Redshift.Parser-34"><a href="#Redshift.Parser-34"><span class="linenos">34</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
+</span><span id="Redshift.Parser-35"><a href="#Redshift.Parser-35"><span class="linenos">35</span></a> <span class="p">),</span>
+</span><span id="Redshift.Parser-36"><a href="#Redshift.Parser-36"><span class="linenos">36</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">(</span>
+</span><span id="Redshift.Parser-37"><a href="#Redshift.Parser-37"><span class="linenos">37</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span>
+</span><span id="Redshift.Parser-38"><a href="#Redshift.Parser-38"><span class="linenos">38</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span>
+</span><span id="Redshift.Parser-39"><a href="#Redshift.Parser-39"><span class="linenos">39</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
+</span><span id="Redshift.Parser-40"><a href="#Redshift.Parser-40"><span class="linenos">40</span></a> <span class="p">),</span>
+</span><span id="Redshift.Parser-41"><a href="#Redshift.Parser-41"><span class="linenos">41</span></a> <span class="s2">&quot;NVL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
+</span><span id="Redshift.Parser-42"><a href="#Redshift.Parser-42"><span class="linenos">42</span></a> <span class="s2">&quot;STRTOL&quot;</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span>
+</span><span id="Redshift.Parser-43"><a href="#Redshift.Parser-43"><span class="linenos">43</span></a> <span class="p">}</span>
+</span><span id="Redshift.Parser-44"><a href="#Redshift.Parser-44"><span class="linenos">44</span></a>
+</span><span id="Redshift.Parser-45"><a href="#Redshift.Parser-45"><span class="linenos">45</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span>
+</span><span id="Redshift.Parser-46"><a href="#Redshift.Parser-46"><span class="linenos">46</span></a>
+</span><span id="Redshift.Parser-47"><a href="#Redshift.Parser-47"><span class="linenos">47</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span>
+</span><span id="Redshift.Parser-48"><a href="#Redshift.Parser-48"><span class="linenos">48</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
+</span><span id="Redshift.Parser-49"><a href="#Redshift.Parser-49"><span class="linenos">49</span></a> <span class="p">)</span> <span class="o">-&gt;</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span>
+</span><span id="Redshift.Parser-50"><a href="#Redshift.Parser-50"><span class="linenos">50</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span>
+</span><span id="Redshift.Parser-51"><a href="#Redshift.Parser-51"><span class="linenos">51</span></a>
+</span><span id="Redshift.Parser-52"><a href="#Redshift.Parser-52"><span class="linenos">52</span></a> <span class="k">if</span> <span class="p">(</span>
+</span><span id="Redshift.Parser-53"><a href="#Redshift.Parser-53"><span class="linenos">53</span></a> <span class="nb">isinstance</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span>
+</span><span id="Redshift.Parser-54"><a href="#Redshift.Parser-54"><span class="linenos">54</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;varchar&quot;</span><span class="p">)</span>
+</span><span id="Redshift.Parser-55"><a href="#Redshift.Parser-55"><span class="linenos">55</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span>
+</span><span id="Redshift.Parser-56"><a href="#Redshift.Parser-56"><span class="linenos">56</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)</span>
+</span><span id="Redshift.Parser-57"><a href="#Redshift.Parser-57"><span class="linenos">57</span></a> <span class="p">):</span>
+</span><span id="Redshift.Parser-58"><a href="#Redshift.Parser-58"><span class="linenos">58</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">,</span> <span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">&quot;MAX&quot;</span><span class="p">)])</span>
+</span><span id="Redshift.Parser-59"><a href="#Redshift.Parser-59"><span class="linenos">59</span></a>
+</span><span id="Redshift.Parser-60"><a href="#Redshift.Parser-60"><span class="linenos">60</span></a> <span class="k">return</span> <span class="n">this</span>
</span></pre></div>
@@ -555,26 +568,26 @@ Default: 3</li>
</div>
<a class="headerlink" href="#Redshift.Tokenizer"></a>
- <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Tokenizer-59"><a href="#Redshift.Tokenizer-59"><span class="linenos">59</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span>
-</span><span id="Redshift.Tokenizer-60"><a href="#Redshift.Tokenizer-60"><span class="linenos">60</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="Redshift.Tokenizer-61"><a href="#Redshift.Tokenizer-61"><span class="linenos">61</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="Redshift.Tokenizer-62"><a href="#Redshift.Tokenizer-62"><span class="linenos">62</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">]</span>
-</span><span id="Redshift.Tokenizer-63"><a href="#Redshift.Tokenizer-63"><span class="linenos">63</span></a>
-</span><span id="Redshift.Tokenizer-64"><a href="#Redshift.Tokenizer-64"><span class="linenos">64</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift.Tokenizer-65"><a href="#Redshift.Tokenizer-65"><span class="linenos">65</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span>
-</span><span id="Redshift.Tokenizer-66"><a href="#Redshift.Tokenizer-66"><span class="linenos">66</span></a> <span class="s2">&quot;HLLSKETCH&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span>
-</span><span id="Redshift.Tokenizer-67"><a href="#Redshift.Tokenizer-67"><span class="linenos">67</span></a> <span class="s2">&quot;SUPER&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span>
-</span><span id="Redshift.Tokenizer-68"><a href="#Redshift.Tokenizer-68"><span class="linenos">68</span></a> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span>
-</span><span id="Redshift.Tokenizer-69"><a href="#Redshift.Tokenizer-69"><span class="linenos">69</span></a> <span class="s2">&quot;TIME&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span>
-</span><span id="Redshift.Tokenizer-70"><a href="#Redshift.Tokenizer-70"><span class="linenos">70</span></a> <span class="s2">&quot;TIMETZ&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span>
-</span><span id="Redshift.Tokenizer-71"><a href="#Redshift.Tokenizer-71"><span class="linenos">71</span></a> <span class="s2">&quot;TOP&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span>
-</span><span id="Redshift.Tokenizer-72"><a href="#Redshift.Tokenizer-72"><span class="linenos">72</span></a> <span class="s2">&quot;UNLOAD&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span>
-</span><span id="Redshift.Tokenizer-73"><a href="#Redshift.Tokenizer-73"><span class="linenos">73</span></a> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span>
-</span><span id="Redshift.Tokenizer-74"><a href="#Redshift.Tokenizer-74"><span class="linenos">74</span></a> <span class="p">}</span>
-</span><span id="Redshift.Tokenizer-75"><a href="#Redshift.Tokenizer-75"><span class="linenos">75</span></a>
-</span><span id="Redshift.Tokenizer-76"><a href="#Redshift.Tokenizer-76"><span class="linenos">76</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span>
-</span><span id="Redshift.Tokenizer-77"><a href="#Redshift.Tokenizer-77"><span class="linenos">77</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
-</span><span id="Redshift.Tokenizer-78"><a href="#Redshift.Tokenizer-78"><span class="linenos">78</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;#&quot;</span><span class="p">)</span>
+ <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Tokenizer-62"><a href="#Redshift.Tokenizer-62"><span class="linenos">62</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span>
+</span><span id="Redshift.Tokenizer-63"><a href="#Redshift.Tokenizer-63"><span class="linenos">63</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="Redshift.Tokenizer-64"><a href="#Redshift.Tokenizer-64"><span class="linenos">64</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="Redshift.Tokenizer-65"><a href="#Redshift.Tokenizer-65"><span class="linenos">65</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">]</span>
+</span><span id="Redshift.Tokenizer-66"><a href="#Redshift.Tokenizer-66"><span class="linenos">66</span></a>
+</span><span id="Redshift.Tokenizer-67"><a href="#Redshift.Tokenizer-67"><span class="linenos">67</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift.Tokenizer-68"><a href="#Redshift.Tokenizer-68"><span class="linenos">68</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span>
+</span><span id="Redshift.Tokenizer-69"><a href="#Redshift.Tokenizer-69"><span class="linenos">69</span></a> <span class="s2">&quot;HLLSKETCH&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span>
+</span><span id="Redshift.Tokenizer-70"><a href="#Redshift.Tokenizer-70"><span class="linenos">70</span></a> <span class="s2">&quot;SUPER&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span>
+</span><span id="Redshift.Tokenizer-71"><a href="#Redshift.Tokenizer-71"><span class="linenos">71</span></a> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span>
+</span><span id="Redshift.Tokenizer-72"><a href="#Redshift.Tokenizer-72"><span class="linenos">72</span></a> <span class="s2">&quot;TIME&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span>
+</span><span id="Redshift.Tokenizer-73"><a href="#Redshift.Tokenizer-73"><span class="linenos">73</span></a> <span class="s2">&quot;TIMETZ&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span>
+</span><span id="Redshift.Tokenizer-74"><a href="#Redshift.Tokenizer-74"><span class="linenos">74</span></a> <span class="s2">&quot;TOP&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span>
+</span><span id="Redshift.Tokenizer-75"><a href="#Redshift.Tokenizer-75"><span class="linenos">75</span></a> <span class="s2">&quot;UNLOAD&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span>
+</span><span id="Redshift.Tokenizer-76"><a href="#Redshift.Tokenizer-76"><span class="linenos">76</span></a> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span>
+</span><span id="Redshift.Tokenizer-77"><a href="#Redshift.Tokenizer-77"><span class="linenos">77</span></a> <span class="p">}</span>
+</span><span id="Redshift.Tokenizer-78"><a href="#Redshift.Tokenizer-78"><span class="linenos">78</span></a>
+</span><span id="Redshift.Tokenizer-79"><a href="#Redshift.Tokenizer-79"><span class="linenos">79</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span>
+</span><span id="Redshift.Tokenizer-80"><a href="#Redshift.Tokenizer-80"><span class="linenos">80</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
+</span><span id="Redshift.Tokenizer-81"><a href="#Redshift.Tokenizer-81"><span class="linenos">81</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;#&quot;</span><span class="p">)</span>
</span></pre></div>
@@ -603,105 +616,105 @@ Default: 3</li>
</div>
<a class="headerlink" href="#Redshift.Generator"></a>
- <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator-80"><a href="#Redshift.Generator-80"><span class="linenos"> 80</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span>
-</span><span id="Redshift.Generator-81"><a href="#Redshift.Generator-81"><span class="linenos"> 81</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span>
-</span><span id="Redshift.Generator-82"><a href="#Redshift.Generator-82"><span class="linenos"> 82</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span>
-</span><span id="Redshift.Generator-83"><a href="#Redshift.Generator-83"><span class="linenos"> 83</span></a>
-</span><span id="Redshift.Generator-84"><a href="#Redshift.Generator-84"><span class="linenos"> 84</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift.Generator-85"><a href="#Redshift.Generator-85"><span class="linenos"> 85</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span>
-</span><span id="Redshift.Generator-86"><a href="#Redshift.Generator-86"><span class="linenos"> 86</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
-</span><span id="Redshift.Generator-87"><a href="#Redshift.Generator-87"><span class="linenos"> 87</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
-</span><span id="Redshift.Generator-88"><a href="#Redshift.Generator-88"><span class="linenos"> 88</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">&quot;INTEGER&quot;</span><span class="p">,</span>
-</span><span id="Redshift.Generator-89"><a href="#Redshift.Generator-89"><span class="linenos"> 89</span></a> <span class="p">}</span>
-</span><span id="Redshift.Generator-90"><a href="#Redshift.Generator-90"><span class="linenos"> 90</span></a>
-</span><span id="Redshift.Generator-91"><a href="#Redshift.Generator-91"><span class="linenos"> 91</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift.Generator-92"><a href="#Redshift.Generator-92"><span class="linenos"> 92</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span>
-</span><span id="Redshift.Generator-93"><a href="#Redshift.Generator-93"><span class="linenos"> 93</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span>
-</span><span id="Redshift.Generator-94"><a href="#Redshift.Generator-94"><span class="linenos"> 94</span></a> <span class="p">}</span>
-</span><span id="Redshift.Generator-95"><a href="#Redshift.Generator-95"><span class="linenos"> 95</span></a>
-</span><span id="Redshift.Generator-96"><a href="#Redshift.Generator-96"><span class="linenos"> 96</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span>
-</span><span id="Redshift.Generator-97"><a href="#Redshift.Generator-97"><span class="linenos"> 97</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span>
-</span><span id="Redshift.Generator-98"><a href="#Redshift.Generator-98"><span class="linenos"> 98</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
-</span><span id="Redshift.Generator-99"><a href="#Redshift.Generator-99"><span class="linenos"> 99</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">,</span>
-</span><span id="Redshift.Generator-100"><a href="#Redshift.Generator-100"><span class="linenos">100</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
-</span><span id="Redshift.Generator-101"><a href="#Redshift.Generator-101"><span class="linenos">101</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
-</span><span id="Redshift.Generator-102"><a href="#Redshift.Generator-102"><span class="linenos">102</span></a> <span class="p">),</span>
-</span><span id="Redshift.Generator-103"><a href="#Redshift.Generator-103"><span class="linenos">103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
-</span><span id="Redshift.Generator-104"><a href="#Redshift.Generator-104"><span class="linenos">104</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
+ <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator-83"><a href="#Redshift.Generator-83"><span class="linenos"> 83</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span>
+</span><span id="Redshift.Generator-84"><a href="#Redshift.Generator-84"><span class="linenos"> 84</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span>
+</span><span id="Redshift.Generator-85"><a href="#Redshift.Generator-85"><span class="linenos"> 85</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span>
+</span><span id="Redshift.Generator-86"><a href="#Redshift.Generator-86"><span class="linenos"> 86</span></a>
+</span><span id="Redshift.Generator-87"><a href="#Redshift.Generator-87"><span class="linenos"> 87</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift.Generator-88"><a href="#Redshift.Generator-88"><span class="linenos"> 88</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span>
+</span><span id="Redshift.Generator-89"><a href="#Redshift.Generator-89"><span class="linenos"> 89</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
+</span><span id="Redshift.Generator-90"><a href="#Redshift.Generator-90"><span class="linenos"> 90</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">&quot;VARBYTE&quot;</span><span class="p">,</span>
+</span><span id="Redshift.Generator-91"><a href="#Redshift.Generator-91"><span class="linenos"> 91</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">&quot;INTEGER&quot;</span><span class="p">,</span>
+</span><span id="Redshift.Generator-92"><a href="#Redshift.Generator-92"><span class="linenos"> 92</span></a> <span class="p">}</span>
+</span><span id="Redshift.Generator-93"><a href="#Redshift.Generator-93"><span class="linenos"> 93</span></a>
+</span><span id="Redshift.Generator-94"><a href="#Redshift.Generator-94"><span class="linenos"> 94</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift.Generator-95"><a href="#Redshift.Generator-95"><span class="linenos"> 95</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span>
+</span><span id="Redshift.Generator-96"><a href="#Redshift.Generator-96"><span class="linenos"> 96</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span>
+</span><span id="Redshift.Generator-97"><a href="#Redshift.Generator-97"><span class="linenos"> 97</span></a> <span class="p">}</span>
+</span><span id="Redshift.Generator-98"><a href="#Redshift.Generator-98"><span class="linenos"> 98</span></a>
+</span><span id="Redshift.Generator-99"><a href="#Redshift.Generator-99"><span class="linenos"> 99</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span>
+</span><span id="Redshift.Generator-100"><a href="#Redshift.Generator-100"><span class="linenos">100</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span>
+</span><span id="Redshift.Generator-101"><a href="#Redshift.Generator-101"><span class="linenos">101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
+</span><span id="Redshift.Generator-102"><a href="#Redshift.Generator-102"><span class="linenos">102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">&quot;SYSDATE&quot;</span><span class="p">,</span>
+</span><span id="Redshift.Generator-103"><a href="#Redshift.Generator-103"><span class="linenos">103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
+</span><span id="Redshift.Generator-104"><a href="#Redshift.Generator-104"><span class="linenos">104</span></a> <span class="s2">&quot;DATEADD&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
</span><span id="Redshift.Generator-105"><a href="#Redshift.Generator-105"><span class="linenos">105</span></a> <span class="p">),</span>
-</span><span id="Redshift.Generator-106"><a href="#Redshift.Generator-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)&quot;</span><span class="p">,</span>
-</span><span id="Redshift.Generator-107"><a href="#Redshift.Generator-107"><span class="linenos">107</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span>
-</span><span id="Redshift.Generator-108"><a href="#Redshift.Generator-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">&quot;STRTOL&quot;</span><span class="p">),</span>
-</span><span id="Redshift.Generator-109"><a href="#Redshift.Generator-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
-</span><span id="Redshift.Generator-110"><a href="#Redshift.Generator-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
-</span><span id="Redshift.Generator-111"><a href="#Redshift.Generator-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
-</span><span id="Redshift.Generator-112"><a href="#Redshift.Generator-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]),</span>
-</span><span id="Redshift.Generator-113"><a href="#Redshift.Generator-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="s1">&#39;COMPOUND &#39;</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">&#39;compound&#39;</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">&#39;&#39;</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">)&quot;</span><span class="p">,</span>
-</span><span id="Redshift.Generator-114"><a href="#Redshift.Generator-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span>
-</span><span id="Redshift.Generator-115"><a href="#Redshift.Generator-115"><span class="linenos">115</span></a> <span class="p">}</span>
-</span><span id="Redshift.Generator-116"><a href="#Redshift.Generator-116"><span class="linenos">116</span></a>
-</span><span id="Redshift.Generator-117"><a href="#Redshift.Generator-117"><span class="linenos">117</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span>
-</span><span id="Redshift.Generator-118"><a href="#Redshift.Generator-118"><span class="linenos">118</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span>
+</span><span id="Redshift.Generator-106"><a href="#Redshift.Generator-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span>
+</span><span id="Redshift.Generator-107"><a href="#Redshift.Generator-107"><span class="linenos">107</span></a> <span class="s2">&quot;DATEDIFF&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">&quot;unit&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">&quot;day&quot;</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span>
+</span><span id="Redshift.Generator-108"><a href="#Redshift.Generator-108"><span class="linenos">108</span></a> <span class="p">),</span>
+</span><span id="Redshift.Generator-109"><a href="#Redshift.Generator-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)&quot;</span><span class="p">,</span>
+</span><span id="Redshift.Generator-110"><a href="#Redshift.Generator-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span>
+</span><span id="Redshift.Generator-111"><a href="#Redshift.Generator-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">&quot;STRTOL&quot;</span><span class="p">),</span>
+</span><span id="Redshift.Generator-112"><a href="#Redshift.Generator-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
+</span><span id="Redshift.Generator-113"><a href="#Redshift.Generator-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span>
+</span><span id="Redshift.Generator-114"><a href="#Redshift.Generator-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span>
+</span><span id="Redshift.Generator-115"><a href="#Redshift.Generator-115"><span class="linenos">115</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]),</span>
+</span><span id="Redshift.Generator-116"><a href="#Redshift.Generator-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="s1">&#39;COMPOUND &#39;</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">&#39;compound&#39;</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">&#39;&#39;</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">)&quot;</span><span class="p">,</span>
+</span><span id="Redshift.Generator-117"><a href="#Redshift.Generator-117"><span class="linenos">117</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span>
+</span><span id="Redshift.Generator-118"><a href="#Redshift.Generator-118"><span class="linenos">118</span></a> <span class="p">}</span>
</span><span id="Redshift.Generator-119"><a href="#Redshift.Generator-119"><span class="linenos">119</span></a>
-</span><span id="Redshift.Generator-120"><a href="#Redshift.Generator-120"><span class="linenos">120</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span>
-</span><span id="Redshift.Generator-121"><a href="#Redshift.Generator-121"><span class="linenos">121</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span>
+</span><span id="Redshift.Generator-120"><a href="#Redshift.Generator-120"><span class="linenos">120</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span>
+</span><span id="Redshift.Generator-121"><a href="#Redshift.Generator-121"><span class="linenos">121</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span>
</span><span id="Redshift.Generator-122"><a href="#Redshift.Generator-122"><span class="linenos">122</span></a>
-</span><span id="Redshift.Generator-123"><a href="#Redshift.Generator-123"><span class="linenos">123</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">&quot;snapshot&quot;</span><span class="p">,</span> <span class="s2">&quot;type&quot;</span><span class="p">}</span>
-</span><span id="Redshift.Generator-124"><a href="#Redshift.Generator-124"><span class="linenos">124</span></a>
-</span><span id="Redshift.Generator-125"><a href="#Redshift.Generator-125"><span class="linenos">125</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="Redshift.Generator-126"><a href="#Redshift.Generator-126"><span class="linenos">126</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator-127"><a href="#Redshift.Generator-127"><span class="linenos">127</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span>
-</span><span id="Redshift.Generator-128"><a href="#Redshift.Generator-128"><span class="linenos">128</span></a>
-</span><span id="Redshift.Generator-129"><a href="#Redshift.Generator-129"><span class="linenos">129</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span>
-</span><span id="Redshift.Generator-130"><a href="#Redshift.Generator-130"><span class="linenos">130</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span>
-</span><span id="Redshift.Generator-131"><a href="#Redshift.Generator-131"><span class="linenos">131</span></a><span class="sd"> very slow.</span>
-</span><span id="Redshift.Generator-132"><a href="#Redshift.Generator-132"><span class="linenos">132</span></a><span class="sd"> &quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator-133"><a href="#Redshift.Generator-133"><span class="linenos">133</span></a>
-</span><span id="Redshift.Generator-134"><a href="#Redshift.Generator-134"><span class="linenos">134</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span>
-</span><span id="Redshift.Generator-135"><a href="#Redshift.Generator-135"><span class="linenos">135</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span>
-</span><span id="Redshift.Generator-136"><a href="#Redshift.Generator-136"><span class="linenos">136</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
-</span><span id="Redshift.Generator-137"><a href="#Redshift.Generator-137"><span class="linenos">137</span></a>
-</span><span id="Redshift.Generator-138"><a href="#Redshift.Generator-138"><span class="linenos">138</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;alias&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span>
-</span><span id="Redshift.Generator-139"><a href="#Redshift.Generator-139"><span class="linenos">139</span></a>
-</span><span id="Redshift.Generator-140"><a href="#Redshift.Generator-140"><span class="linenos">140</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="Redshift.Generator-141"><a href="#Redshift.Generator-141"><span class="linenos">141</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span>
+</span><span id="Redshift.Generator-123"><a href="#Redshift.Generator-123"><span class="linenos">123</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span>
+</span><span id="Redshift.Generator-124"><a href="#Redshift.Generator-124"><span class="linenos">124</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span>
+</span><span id="Redshift.Generator-125"><a href="#Redshift.Generator-125"><span class="linenos">125</span></a>
+</span><span id="Redshift.Generator-126"><a href="#Redshift.Generator-126"><span class="linenos">126</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">&quot;snapshot&quot;</span><span class="p">,</span> <span class="s2">&quot;type&quot;</span><span class="p">}</span>
+</span><span id="Redshift.Generator-127"><a href="#Redshift.Generator-127"><span class="linenos">127</span></a>
+</span><span id="Redshift.Generator-128"><a href="#Redshift.Generator-128"><span class="linenos">128</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="Redshift.Generator-129"><a href="#Redshift.Generator-129"><span class="linenos">129</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator-130"><a href="#Redshift.Generator-130"><span class="linenos">130</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span>
+</span><span id="Redshift.Generator-131"><a href="#Redshift.Generator-131"><span class="linenos">131</span></a>
+</span><span id="Redshift.Generator-132"><a href="#Redshift.Generator-132"><span class="linenos">132</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span>
+</span><span id="Redshift.Generator-133"><a href="#Redshift.Generator-133"><span class="linenos">133</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span>
+</span><span id="Redshift.Generator-134"><a href="#Redshift.Generator-134"><span class="linenos">134</span></a><span class="sd"> very slow.</span>
+</span><span id="Redshift.Generator-135"><a href="#Redshift.Generator-135"><span class="linenos">135</span></a><span class="sd"> &quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator-136"><a href="#Redshift.Generator-136"><span class="linenos">136</span></a>
+</span><span id="Redshift.Generator-137"><a href="#Redshift.Generator-137"><span class="linenos">137</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span>
+</span><span id="Redshift.Generator-138"><a href="#Redshift.Generator-138"><span class="linenos">138</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span>
+</span><span id="Redshift.Generator-139"><a href="#Redshift.Generator-139"><span class="linenos">139</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
+</span><span id="Redshift.Generator-140"><a href="#Redshift.Generator-140"><span class="linenos">140</span></a>
+</span><span id="Redshift.Generator-141"><a href="#Redshift.Generator-141"><span class="linenos">141</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;alias&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span>
</span><span id="Redshift.Generator-142"><a href="#Redshift.Generator-142"><span class="linenos">142</span></a>
-</span><span id="Redshift.Generator-143"><a href="#Redshift.Generator-143"><span class="linenos">143</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span>
-</span><span id="Redshift.Generator-144"><a href="#Redshift.Generator-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span>
-</span><span id="Redshift.Generator-145"><a href="#Redshift.Generator-145"><span class="linenos">145</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span>
-</span><span id="Redshift.Generator-146"><a href="#Redshift.Generator-146"><span class="linenos">146</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span>
-</span><span id="Redshift.Generator-147"><a href="#Redshift.Generator-147"><span class="linenos">147</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span>
-</span><span id="Redshift.Generator-148"><a href="#Redshift.Generator-148"><span class="linenos">148</span></a> <span class="p">]</span>
-</span><span id="Redshift.Generator-149"><a href="#Redshift.Generator-149"><span class="linenos">149</span></a>
-</span><span id="Redshift.Generator-150"><a href="#Redshift.Generator-150"><span class="linenos">150</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span>
-</span><span id="Redshift.Generator-151"><a href="#Redshift.Generator-151"><span class="linenos">151</span></a>
-</span><span id="Redshift.Generator-152"><a href="#Redshift.Generator-152"><span class="linenos">152</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
-</span><span id="Redshift.Generator-153"><a href="#Redshift.Generator-153"><span class="linenos">153</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
-</span><span id="Redshift.Generator-154"><a href="#Redshift.Generator-154"><span class="linenos">154</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
-</span><span id="Redshift.Generator-155"><a href="#Redshift.Generator-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
-</span><span id="Redshift.Generator-156"><a href="#Redshift.Generator-156"><span class="linenos">156</span></a>
-</span><span id="Redshift.Generator-157"><a href="#Redshift.Generator-157"><span class="linenos">157</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span>
-</span><span id="Redshift.Generator-158"><a href="#Redshift.Generator-158"><span class="linenos">158</span></a>
-</span><span id="Redshift.Generator-159"><a href="#Redshift.Generator-159"><span class="linenos">159</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="Redshift.Generator-160"><a href="#Redshift.Generator-160"><span class="linenos">160</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;Redshift doesn&#39;t have `WITH` as part of their with_properties so we remove it&quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator-161"><a href="#Redshift.Generator-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
-</span><span id="Redshift.Generator-162"><a href="#Redshift.Generator-162"><span class="linenos">162</span></a>
-</span><span id="Redshift.Generator-163"><a href="#Redshift.Generator-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="Redshift.Generator-164"><a href="#Redshift.Generator-164"><span class="linenos">164</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator-165"><a href="#Redshift.Generator-165"><span class="linenos">165</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span>
-</span><span id="Redshift.Generator-166"><a href="#Redshift.Generator-166"><span class="linenos">166</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span>
-</span><span id="Redshift.Generator-167"><a href="#Redshift.Generator-167"><span class="linenos">167</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span>
-</span><span id="Redshift.Generator-168"><a href="#Redshift.Generator-168"><span class="linenos">168</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span>
-</span><span id="Redshift.Generator-169"><a href="#Redshift.Generator-169"><span class="linenos">169</span></a><span class="sd"> &quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator-170"><a href="#Redshift.Generator-170"><span class="linenos">170</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;text&quot;</span><span class="p">):</span>
-</span><span id="Redshift.Generator-171"><a href="#Redshift.Generator-171"><span class="linenos">171</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
-</span><span id="Redshift.Generator-172"><a href="#Redshift.Generator-172"><span class="linenos">172</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;this&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span>
-</span><span id="Redshift.Generator-173"><a href="#Redshift.Generator-173"><span class="linenos">173</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">)</span>
-</span><span id="Redshift.Generator-174"><a href="#Redshift.Generator-174"><span class="linenos">174</span></a>
-</span><span id="Redshift.Generator-175"><a href="#Redshift.Generator-175"><span class="linenos">175</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span>
-</span><span id="Redshift.Generator-176"><a href="#Redshift.Generator-176"><span class="linenos">176</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</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">&quot;MAX&quot;</span><span class="p">))</span>
+</span><span id="Redshift.Generator-143"><a href="#Redshift.Generator-143"><span class="linenos">143</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="Redshift.Generator-144"><a href="#Redshift.Generator-144"><span class="linenos">144</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span>
+</span><span id="Redshift.Generator-145"><a href="#Redshift.Generator-145"><span class="linenos">145</span></a>
+</span><span id="Redshift.Generator-146"><a href="#Redshift.Generator-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span>
+</span><span id="Redshift.Generator-147"><a href="#Redshift.Generator-147"><span class="linenos">147</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span>
+</span><span id="Redshift.Generator-148"><a href="#Redshift.Generator-148"><span class="linenos">148</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span>
+</span><span id="Redshift.Generator-149"><a href="#Redshift.Generator-149"><span class="linenos">149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span>
+</span><span id="Redshift.Generator-150"><a href="#Redshift.Generator-150"><span class="linenos">150</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span>
+</span><span id="Redshift.Generator-151"><a href="#Redshift.Generator-151"><span class="linenos">151</span></a> <span class="p">]</span>
+</span><span id="Redshift.Generator-152"><a href="#Redshift.Generator-152"><span class="linenos">152</span></a>
+</span><span id="Redshift.Generator-153"><a href="#Redshift.Generator-153"><span class="linenos">153</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span>
+</span><span id="Redshift.Generator-154"><a href="#Redshift.Generator-154"><span class="linenos">154</span></a>
+</span><span id="Redshift.Generator-155"><a href="#Redshift.Generator-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+</span><span id="Redshift.Generator-156"><a href="#Redshift.Generator-156"><span class="linenos">156</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
+</span><span id="Redshift.Generator-157"><a href="#Redshift.Generator-157"><span class="linenos">157</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
+</span><span id="Redshift.Generator-158"><a href="#Redshift.Generator-158"><span class="linenos">158</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
+</span><span id="Redshift.Generator-159"><a href="#Redshift.Generator-159"><span class="linenos">159</span></a>
+</span><span id="Redshift.Generator-160"><a href="#Redshift.Generator-160"><span class="linenos">160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span>
+</span><span id="Redshift.Generator-161"><a href="#Redshift.Generator-161"><span class="linenos">161</span></a>
+</span><span id="Redshift.Generator-162"><a href="#Redshift.Generator-162"><span class="linenos">162</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="Redshift.Generator-163"><a href="#Redshift.Generator-163"><span class="linenos">163</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;Redshift doesn&#39;t have `WITH` as part of their with_properties so we remove it&quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator-164"><a href="#Redshift.Generator-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
+</span><span id="Redshift.Generator-165"><a href="#Redshift.Generator-165"><span class="linenos">165</span></a>
+</span><span id="Redshift.Generator-166"><a href="#Redshift.Generator-166"><span class="linenos">166</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="Redshift.Generator-167"><a href="#Redshift.Generator-167"><span class="linenos">167</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator-168"><a href="#Redshift.Generator-168"><span class="linenos">168</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span>
+</span><span id="Redshift.Generator-169"><a href="#Redshift.Generator-169"><span class="linenos">169</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span>
+</span><span id="Redshift.Generator-170"><a href="#Redshift.Generator-170"><span class="linenos">170</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span>
+</span><span id="Redshift.Generator-171"><a href="#Redshift.Generator-171"><span class="linenos">171</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span>
+</span><span id="Redshift.Generator-172"><a href="#Redshift.Generator-172"><span class="linenos">172</span></a><span class="sd"> &quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator-173"><a href="#Redshift.Generator-173"><span class="linenos">173</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;text&quot;</span><span class="p">):</span>
+</span><span id="Redshift.Generator-174"><a href="#Redshift.Generator-174"><span class="linenos">174</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
+</span><span id="Redshift.Generator-175"><a href="#Redshift.Generator-175"><span class="linenos">175</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;this&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span>
+</span><span id="Redshift.Generator-176"><a href="#Redshift.Generator-176"><span class="linenos">176</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">)</span>
</span><span id="Redshift.Generator-177"><a href="#Redshift.Generator-177"><span class="linenos">177</span></a>
-</span><span id="Redshift.Generator-178"><a href="#Redshift.Generator-178"><span class="linenos">178</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
+</span><span id="Redshift.Generator-178"><a href="#Redshift.Generator-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span>
+</span><span id="Redshift.Generator-179"><a href="#Redshift.Generator-179"><span class="linenos">179</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</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">&quot;MAX&quot;</span><span class="p">))</span>
+</span><span id="Redshift.Generator-180"><a href="#Redshift.Generator-180"><span class="linenos">180</span></a>
+</span><span id="Redshift.Generator-181"><a href="#Redshift.Generator-181"><span class="linenos">181</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
</span></pre></div>
@@ -755,39 +768,39 @@ Default: True</li>
</div>
<a class="headerlink" href="#Redshift.Generator.values_sql"></a>
- <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.values_sql-125"><a href="#Redshift.Generator.values_sql-125"><span class="linenos">125</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="Redshift.Generator.values_sql-126"><a href="#Redshift.Generator.values_sql-126"><span class="linenos">126</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator.values_sql-127"><a href="#Redshift.Generator.values_sql-127"><span class="linenos">127</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span>
-</span><span id="Redshift.Generator.values_sql-128"><a href="#Redshift.Generator.values_sql-128"><span class="linenos">128</span></a>
-</span><span id="Redshift.Generator.values_sql-129"><a href="#Redshift.Generator.values_sql-129"><span class="linenos">129</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span>
-</span><span id="Redshift.Generator.values_sql-130"><a href="#Redshift.Generator.values_sql-130"><span class="linenos">130</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span>
-</span><span id="Redshift.Generator.values_sql-131"><a href="#Redshift.Generator.values_sql-131"><span class="linenos">131</span></a><span class="sd"> very slow.</span>
-</span><span id="Redshift.Generator.values_sql-132"><a href="#Redshift.Generator.values_sql-132"><span class="linenos">132</span></a><span class="sd"> &quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator.values_sql-133"><a href="#Redshift.Generator.values_sql-133"><span class="linenos">133</span></a>
-</span><span id="Redshift.Generator.values_sql-134"><a href="#Redshift.Generator.values_sql-134"><span class="linenos">134</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span>
-</span><span id="Redshift.Generator.values_sql-135"><a href="#Redshift.Generator.values_sql-135"><span class="linenos">135</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span>
-</span><span id="Redshift.Generator.values_sql-136"><a href="#Redshift.Generator.values_sql-136"><span class="linenos">136</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
-</span><span id="Redshift.Generator.values_sql-137"><a href="#Redshift.Generator.values_sql-137"><span class="linenos">137</span></a>
-</span><span id="Redshift.Generator.values_sql-138"><a href="#Redshift.Generator.values_sql-138"><span class="linenos">138</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;alias&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span>
-</span><span id="Redshift.Generator.values_sql-139"><a href="#Redshift.Generator.values_sql-139"><span class="linenos">139</span></a>
-</span><span id="Redshift.Generator.values_sql-140"><a href="#Redshift.Generator.values_sql-140"><span class="linenos">140</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span>
-</span><span id="Redshift.Generator.values_sql-141"><a href="#Redshift.Generator.values_sql-141"><span class="linenos">141</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span>
+ <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.values_sql-128"><a href="#Redshift.Generator.values_sql-128"><span class="linenos">128</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="Redshift.Generator.values_sql-129"><a href="#Redshift.Generator.values_sql-129"><span class="linenos">129</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator.values_sql-130"><a href="#Redshift.Generator.values_sql-130"><span class="linenos">130</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span>
+</span><span id="Redshift.Generator.values_sql-131"><a href="#Redshift.Generator.values_sql-131"><span class="linenos">131</span></a>
+</span><span id="Redshift.Generator.values_sql-132"><a href="#Redshift.Generator.values_sql-132"><span class="linenos">132</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span>
+</span><span id="Redshift.Generator.values_sql-133"><a href="#Redshift.Generator.values_sql-133"><span class="linenos">133</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span>
+</span><span id="Redshift.Generator.values_sql-134"><a href="#Redshift.Generator.values_sql-134"><span class="linenos">134</span></a><span class="sd"> very slow.</span>
+</span><span id="Redshift.Generator.values_sql-135"><a href="#Redshift.Generator.values_sql-135"><span class="linenos">135</span></a><span class="sd"> &quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator.values_sql-136"><a href="#Redshift.Generator.values_sql-136"><span class="linenos">136</span></a>
+</span><span id="Redshift.Generator.values_sql-137"><a href="#Redshift.Generator.values_sql-137"><span class="linenos">137</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span>
+</span><span id="Redshift.Generator.values_sql-138"><a href="#Redshift.Generator.values_sql-138"><span class="linenos">138</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span>
+</span><span id="Redshift.Generator.values_sql-139"><a href="#Redshift.Generator.values_sql-139"><span class="linenos">139</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
+</span><span id="Redshift.Generator.values_sql-140"><a href="#Redshift.Generator.values_sql-140"><span class="linenos">140</span></a>
+</span><span id="Redshift.Generator.values_sql-141"><a href="#Redshift.Generator.values_sql-141"><span class="linenos">141</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;alias&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span>
</span><span id="Redshift.Generator.values_sql-142"><a href="#Redshift.Generator.values_sql-142"><span class="linenos">142</span></a>
-</span><span id="Redshift.Generator.values_sql-143"><a href="#Redshift.Generator.values_sql-143"><span class="linenos">143</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span>
-</span><span id="Redshift.Generator.values_sql-144"><a href="#Redshift.Generator.values_sql-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span>
-</span><span id="Redshift.Generator.values_sql-145"><a href="#Redshift.Generator.values_sql-145"><span class="linenos">145</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span>
-</span><span id="Redshift.Generator.values_sql-146"><a href="#Redshift.Generator.values_sql-146"><span class="linenos">146</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span>
-</span><span id="Redshift.Generator.values_sql-147"><a href="#Redshift.Generator.values_sql-147"><span class="linenos">147</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span>
-</span><span id="Redshift.Generator.values_sql-148"><a href="#Redshift.Generator.values_sql-148"><span class="linenos">148</span></a> <span class="p">]</span>
-</span><span id="Redshift.Generator.values_sql-149"><a href="#Redshift.Generator.values_sql-149"><span class="linenos">149</span></a>
-</span><span id="Redshift.Generator.values_sql-150"><a href="#Redshift.Generator.values_sql-150"><span class="linenos">150</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span>
-</span><span id="Redshift.Generator.values_sql-151"><a href="#Redshift.Generator.values_sql-151"><span class="linenos">151</span></a>
-</span><span id="Redshift.Generator.values_sql-152"><a href="#Redshift.Generator.values_sql-152"><span class="linenos">152</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
-</span><span id="Redshift.Generator.values_sql-153"><a href="#Redshift.Generator.values_sql-153"><span class="linenos">153</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
-</span><span id="Redshift.Generator.values_sql-154"><a href="#Redshift.Generator.values_sql-154"><span class="linenos">154</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
-</span><span id="Redshift.Generator.values_sql-155"><a href="#Redshift.Generator.values_sql-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
-</span><span id="Redshift.Generator.values_sql-156"><a href="#Redshift.Generator.values_sql-156"><span class="linenos">156</span></a>
-</span><span id="Redshift.Generator.values_sql-157"><a href="#Redshift.Generator.values_sql-157"><span class="linenos">157</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span>
+</span><span id="Redshift.Generator.values_sql-143"><a href="#Redshift.Generator.values_sql-143"><span class="linenos">143</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span>
+</span><span id="Redshift.Generator.values_sql-144"><a href="#Redshift.Generator.values_sql-144"><span class="linenos">144</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span>
+</span><span id="Redshift.Generator.values_sql-145"><a href="#Redshift.Generator.values_sql-145"><span class="linenos">145</span></a>
+</span><span id="Redshift.Generator.values_sql-146"><a href="#Redshift.Generator.values_sql-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span>
+</span><span id="Redshift.Generator.values_sql-147"><a href="#Redshift.Generator.values_sql-147"><span class="linenos">147</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span>
+</span><span id="Redshift.Generator.values_sql-148"><a href="#Redshift.Generator.values_sql-148"><span class="linenos">148</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span>
+</span><span id="Redshift.Generator.values_sql-149"><a href="#Redshift.Generator.values_sql-149"><span class="linenos">149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span>
+</span><span id="Redshift.Generator.values_sql-150"><a href="#Redshift.Generator.values_sql-150"><span class="linenos">150</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span>
+</span><span id="Redshift.Generator.values_sql-151"><a href="#Redshift.Generator.values_sql-151"><span class="linenos">151</span></a> <span class="p">]</span>
+</span><span id="Redshift.Generator.values_sql-152"><a href="#Redshift.Generator.values_sql-152"><span class="linenos">152</span></a>
+</span><span id="Redshift.Generator.values_sql-153"><a href="#Redshift.Generator.values_sql-153"><span class="linenos">153</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span>
+</span><span id="Redshift.Generator.values_sql-154"><a href="#Redshift.Generator.values_sql-154"><span class="linenos">154</span></a>
+</span><span id="Redshift.Generator.values_sql-155"><a href="#Redshift.Generator.values_sql-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+</span><span id="Redshift.Generator.values_sql-156"><a href="#Redshift.Generator.values_sql-156"><span class="linenos">156</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
+</span><span id="Redshift.Generator.values_sql-157"><a href="#Redshift.Generator.values_sql-157"><span class="linenos">157</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
+</span><span id="Redshift.Generator.values_sql-158"><a href="#Redshift.Generator.values_sql-158"><span class="linenos">158</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
+</span><span id="Redshift.Generator.values_sql-159"><a href="#Redshift.Generator.values_sql-159"><span class="linenos">159</span></a>
+</span><span id="Redshift.Generator.values_sql-160"><a href="#Redshift.Generator.values_sql-160"><span class="linenos">160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span>
</span></pre></div>
@@ -811,9 +824,9 @@ very slow.</p>
</div>
<a class="headerlink" href="#Redshift.Generator.with_properties"></a>
- <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.with_properties-159"><a href="#Redshift.Generator.with_properties-159"><span class="linenos">159</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="Redshift.Generator.with_properties-160"><a href="#Redshift.Generator.with_properties-160"><span class="linenos">160</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;Redshift doesn&#39;t have `WITH` as part of their with_properties so we remove it&quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator.with_properties-161"><a href="#Redshift.Generator.with_properties-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
+ <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.with_properties-162"><a href="#Redshift.Generator.with_properties-162"><span class="linenos">162</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="Redshift.Generator.with_properties-163"><a href="#Redshift.Generator.with_properties-163"><span class="linenos">163</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;Redshift doesn&#39;t have `WITH` as part of their with_properties so we remove it&quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator.with_properties-164"><a href="#Redshift.Generator.with_properties-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
</span></pre></div>
@@ -833,22 +846,22 @@ very slow.</p>
</div>
<a class="headerlink" href="#Redshift.Generator.datatype_sql"></a>
- <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.datatype_sql-163"><a href="#Redshift.Generator.datatype_sql-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
-</span><span id="Redshift.Generator.datatype_sql-164"><a href="#Redshift.Generator.datatype_sql-164"><span class="linenos">164</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator.datatype_sql-165"><a href="#Redshift.Generator.datatype_sql-165"><span class="linenos">165</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span>
-</span><span id="Redshift.Generator.datatype_sql-166"><a href="#Redshift.Generator.datatype_sql-166"><span class="linenos">166</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span>
-</span><span id="Redshift.Generator.datatype_sql-167"><a href="#Redshift.Generator.datatype_sql-167"><span class="linenos">167</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span>
-</span><span id="Redshift.Generator.datatype_sql-168"><a href="#Redshift.Generator.datatype_sql-168"><span class="linenos">168</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span>
-</span><span id="Redshift.Generator.datatype_sql-169"><a href="#Redshift.Generator.datatype_sql-169"><span class="linenos">169</span></a><span class="sd"> &quot;&quot;&quot;</span>
-</span><span id="Redshift.Generator.datatype_sql-170"><a href="#Redshift.Generator.datatype_sql-170"><span class="linenos">170</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;text&quot;</span><span class="p">):</span>
-</span><span id="Redshift.Generator.datatype_sql-171"><a href="#Redshift.Generator.datatype_sql-171"><span class="linenos">171</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
-</span><span id="Redshift.Generator.datatype_sql-172"><a href="#Redshift.Generator.datatype_sql-172"><span class="linenos">172</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;this&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span>
-</span><span id="Redshift.Generator.datatype_sql-173"><a href="#Redshift.Generator.datatype_sql-173"><span class="linenos">173</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">)</span>
-</span><span id="Redshift.Generator.datatype_sql-174"><a href="#Redshift.Generator.datatype_sql-174"><span class="linenos">174</span></a>
-</span><span id="Redshift.Generator.datatype_sql-175"><a href="#Redshift.Generator.datatype_sql-175"><span class="linenos">175</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span>
-</span><span id="Redshift.Generator.datatype_sql-176"><a href="#Redshift.Generator.datatype_sql-176"><span class="linenos">176</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</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">&quot;MAX&quot;</span><span class="p">))</span>
+ <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.datatype_sql-166"><a href="#Redshift.Generator.datatype_sql-166"><span class="linenos">166</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
+</span><span id="Redshift.Generator.datatype_sql-167"><a href="#Redshift.Generator.datatype_sql-167"><span class="linenos">167</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator.datatype_sql-168"><a href="#Redshift.Generator.datatype_sql-168"><span class="linenos">168</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span>
+</span><span id="Redshift.Generator.datatype_sql-169"><a href="#Redshift.Generator.datatype_sql-169"><span class="linenos">169</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span>
+</span><span id="Redshift.Generator.datatype_sql-170"><a href="#Redshift.Generator.datatype_sql-170"><span class="linenos">170</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span>
+</span><span id="Redshift.Generator.datatype_sql-171"><a href="#Redshift.Generator.datatype_sql-171"><span class="linenos">171</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span>
+</span><span id="Redshift.Generator.datatype_sql-172"><a href="#Redshift.Generator.datatype_sql-172"><span class="linenos">172</span></a><span class="sd"> &quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator.datatype_sql-173"><a href="#Redshift.Generator.datatype_sql-173"><span class="linenos">173</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">&quot;text&quot;</span><span class="p">):</span>
+</span><span id="Redshift.Generator.datatype_sql-174"><a href="#Redshift.Generator.datatype_sql-174"><span class="linenos">174</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
+</span><span id="Redshift.Generator.datatype_sql-175"><a href="#Redshift.Generator.datatype_sql-175"><span class="linenos">175</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">&quot;this&quot;</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">)</span>
+</span><span id="Redshift.Generator.datatype_sql-176"><a href="#Redshift.Generator.datatype_sql-176"><span class="linenos">176</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</span><span class="p">)</span>
</span><span id="Redshift.Generator.datatype_sql-177"><a href="#Redshift.Generator.datatype_sql-177"><span class="linenos">177</span></a>
-</span><span id="Redshift.Generator.datatype_sql-178"><a href="#Redshift.Generator.datatype_sql-178"><span class="linenos">178</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
+</span><span id="Redshift.Generator.datatype_sql-178"><a href="#Redshift.Generator.datatype_sql-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span>
+</span><span id="Redshift.Generator.datatype_sql-179"><a href="#Redshift.Generator.datatype_sql-179"><span class="linenos">179</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;expressions&quot;</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">&quot;MAX&quot;</span><span class="p">))</span>
+</span><span id="Redshift.Generator.datatype_sql-180"><a href="#Redshift.Generator.datatype_sql-180"><span class="linenos">180</span></a>
+</span><span id="Redshift.Generator.datatype_sql-181"><a href="#Redshift.Generator.datatype_sql-181"><span class="linenos">181</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span>
</span></pre></div>
@@ -860,6 +873,60 @@ without precision we convert it to <code>VARCHAR(max)</code> and if it does have
</div>
+ <div id="Redshift.Generator.can_identify" class="classattr">
+ <input id="Redshift.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
+<div class="attr function">
+ <div class="decorator">@classmethod</div>
+
+ <span class="def">def</span>
+ <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">&#39;safe&#39;</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span>
+
+ <label class="view-source-button" for="Redshift.Generator.can_identify-view-source"><span>View Source</span></label>
+
+ </div>
+ <a class="headerlink" href="#Redshift.Generator.can_identify"></a>
+ <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.can_identify-247"><a href="#Redshift.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span>
+</span><span id="Redshift.Generator.can_identify-248"><a href="#Redshift.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">&quot;safe&quot;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
+</span><span id="Redshift.Generator.can_identify-249"><a href="#Redshift.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;Checks if text can be identified given an identify option.</span>
+</span><span id="Redshift.Generator.can_identify-250"><a href="#Redshift.Generator.can_identify-250"><span class="linenos">250</span></a>
+</span><span id="Redshift.Generator.can_identify-251"><a href="#Redshift.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span>
+</span><span id="Redshift.Generator.can_identify-252"><a href="#Redshift.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span>
+</span><span id="Redshift.Generator.can_identify-253"><a href="#Redshift.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span>
+</span><span id="Redshift.Generator.can_identify-254"><a href="#Redshift.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> &quot;always&quot; or `True`: Always returns true.</span>
+</span><span id="Redshift.Generator.can_identify-255"><a href="#Redshift.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> &quot;safe&quot;: True if the identifier is case-insensitive.</span>
+</span><span id="Redshift.Generator.can_identify-256"><a href="#Redshift.Generator.can_identify-256"><span class="linenos">256</span></a>
+</span><span id="Redshift.Generator.can_identify-257"><a href="#Redshift.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span>
+</span><span id="Redshift.Generator.can_identify-258"><a href="#Redshift.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span>
+</span><span id="Redshift.Generator.can_identify-259"><a href="#Redshift.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> &quot;&quot;&quot;</span>
+</span><span id="Redshift.Generator.can_identify-260"><a href="#Redshift.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">&quot;always&quot;</span><span class="p">:</span>
+</span><span id="Redshift.Generator.can_identify-261"><a href="#Redshift.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span>
+</span><span id="Redshift.Generator.can_identify-262"><a href="#Redshift.Generator.can_identify-262"><span class="linenos">262</span></a>
+</span><span id="Redshift.Generator.can_identify-263"><a href="#Redshift.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">&quot;safe&quot;</span><span class="p">:</span>
+</span><span id="Redshift.Generator.can_identify-264"><a href="#Redshift.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
+</span><span id="Redshift.Generator.can_identify-265"><a href="#Redshift.Generator.can_identify-265"><span class="linenos">265</span></a>
+</span><span id="Redshift.Generator.can_identify-266"><a href="#Redshift.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span>
+</span></pre></div>
+
+
+ <div class="docstring"><p>Checks if text can be identified given an identify option.</p>
+
+<h6 id="arguments">Arguments:</h6>
+
+<ul>
+<li><strong>text:</strong> The text to check.</li>
+<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true.
+"safe": True if the identifier is case-insensitive.</li>
+</ul>
+
+<h6 id="returns">Returns:</h6>
+
+<blockquote>
+ <p>Whether or not the given text can be identified.</p>
+</blockquote>
+</div>
+
+
+ </div>
<div class="inherited">
<h5>Inherited Members</h5>
<dl>
@@ -959,6 +1026,7 @@ without precision we convert it to <code>VARCHAR(max)</code> and if it does have
<dd id="Redshift.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd>
<dd id="Redshift.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd>
<dd id="Redshift.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd>
+ <dd id="Redshift.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd>
<dd id="Redshift.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd>
<dd id="Redshift.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd>
<dd id="Redshift.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd>