diff options
Diffstat (limited to 'docs/sqlglot/dialects/teradata.html')
-rw-r--r-- | docs/sqlglot/dialects/teradata.html | 1274 |
1 files changed, 646 insertions, 628 deletions
diff --git a/docs/sqlglot/dialects/teradata.html b/docs/sqlglot/dialects/teradata.html index 128d3c1..32598f0 100644 --- a/docs/sqlglot/dialects/teradata.html +++ b/docs/sqlglot/dialects/teradata.html @@ -61,6 +61,9 @@ <a class="variable" href="#Teradata.Parser.TABLESAMPLE_CSV">TABLESAMPLE_CSV</a> </li> <li> + <a class="variable" href="#Teradata.Parser.VALUES_FOLLOWED_BY_PAREN">VALUES_FOLLOWED_BY_PAREN</a> + </li> + <li> <a class="variable" href="#Teradata.Parser.CHARSET_TRANSLATORS">CHARSET_TRANSLATORS</a> </li> <li> @@ -312,198 +315,199 @@ </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="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> </span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">TABLESAMPLE_CSV</span> <span class="o">=</span> <span class="kc">True</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="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> -</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> -</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="s2">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> <span class="s2">"KANJI1_KANJISJIS_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="s2">"KANJI1_SBC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="s2">"KANJISJIS_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="s2">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> -</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="s2">"LOCALE_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> <span class="s2">"UNICODE_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_PadGraphic"</span><span class="p">,</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_VarGraphic"</span><span class="p">,</span> -</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEBCDIC"</span><span class="p">,</span> -</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEUC"</span><span class="p">,</span> -</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="s2">"UNICODE_TO_KANJI1_KANJISJIS"</span><span class="p">,</span> -</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="s2">"UNICODE_TO_KANJI1_SBC"</span><span class="p">,</span> -</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="s2">"UNICODE_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> <span class="s2">"UNICODE_TO_LATIN"</span><span class="p">,</span> -</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="s2">"UNICODE_TO_LOCALE"</span><span class="p">,</span> -</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a> <span class="s2">"UNICODE_TO_UNICODE_FoldSpace"</span><span class="p">,</span> -</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> -</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> -</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> -</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> -</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> -</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> -</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="p">}</span> -</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> -</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">}</span> -</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="n">FUNC_TOKENS</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">)</span> -</span><span id="L-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="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> -</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="p">),</span> -</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_create</span><span class="p">(),</span> -</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <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="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Data-Type-Conversions/TRYCAST</span> -</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="s2">"TRYCAST"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">[</span><span class="s2">"TRY_CAST"</span><span class="p">],</span> -</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="s2">"RANGE_N"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_rangen</span><span class="p">(),</span> -</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="s2">"TRANSLATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> -</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="p">}</span> -</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> -</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> <span class="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</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-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="p">}</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="k">def</span> <span class="nf">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-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="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">):</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected USING in TRANSLATE"</span><span class="p">)</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">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHARSET_TRANSLATORS</span><span class="p">):</span> -</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">charset_split</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"_TO_"</span><span class="p">)</span> -</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">charset_split</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> -</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected a character set translator after USING in TRANSLATE"</span><span class="p">)</span> -</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> -</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="k">def</span> <span class="nf">_parse_update</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">:</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> -</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">joins</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">)</span> -</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> -</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="p">},</span> -</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="p">)</span> -</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="k">def</span> <span class="nf">_parse_rangen</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">)</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> -</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">each</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"EACH"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RangeN</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">each</span><span class="o">=</span><span class="n">each</span><span class="p">)</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> -</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</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">GEOMETRY</span><span class="p">:</span> <span class="s2">"ST_GEOMETRY"</span><span class="p">,</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="p">}</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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_INDEX</span><span class="p">,</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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_CREATE</span><span class="p">,</span> -</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="p">}</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> -</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pow</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">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"**"</span><span class="p">),</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <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 class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">]</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="p">),</span> -</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</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">"DATABASE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="p">}</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> -</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span> <span class="ow">and</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">"format"</span><span class="p">):</span> -</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="c1"># We don't actually want to print the unknown type in CAST(<value> AS FORMAT <format>)</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> -</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY"</span><span class="p">)</span> -</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> -</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> -</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> -</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> SAMPLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> -</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="k">def</span> <span class="nf">partitionedbyproperty_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">PartitionedByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="k">def</span> <span class="nf">update_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">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"MOD"</span><span class="p">)</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="n">type_sql</span> <span class="o">=</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-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="n">prefix_sql</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">"prefix"</span><span class="p">)</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SYSUDTLIB.</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">prefix_sql</span> <span class="k">else</span> <span class="n">type_sql</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">rangen_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">RangeN</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">)</span> -</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" EACH </span><span class="si">{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">each_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RANGE_N(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"TABLE"</span> <span class="ow">and</span> <span class="n">locations</span><span class="o">.</span><span class="n">get</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_NAME</span><span class="p">):</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="n">this_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="n">this_properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">locations</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_NAME</span><span class="p">]),</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="p">)</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="n">this_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this_name</span><span class="si">}{</span><span class="n">this_properties</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this_schema</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">locations</span><span class="p">)</span> +</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</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="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> +</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> +</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> <span class="s2">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="s2">"KANJI1_KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="s2">"KANJI1_SBC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="s2">"KANJISJIS_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="s2">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> +</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> <span class="s2">"LOCALE_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="s2">"UNICODE_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_PadGraphic"</span><span class="p">,</span> +</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_VarGraphic"</span><span class="p">,</span> +</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEBCDIC"</span><span class="p">,</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEUC"</span><span class="p">,</span> +</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="s2">"UNICODE_TO_KANJI1_KANJISJIS"</span><span class="p">,</span> +</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="s2">"UNICODE_TO_KANJI1_SBC"</span><span class="p">,</span> +</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> <span class="s2">"UNICODE_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="s2">"UNICODE_TO_LATIN"</span><span class="p">,</span> +</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a> <span class="s2">"UNICODE_TO_LOCALE"</span><span class="p">,</span> +</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="s2">"UNICODE_TO_UNICODE_FoldSpace"</span><span class="p">,</span> +</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> +</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> +</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> +</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> +</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> +</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> +</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="p">}</span> +</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> +</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">}</span> +</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="n">FUNC_TOKENS</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">)</span> +</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> +</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> +</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="p">),</span> +</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_create</span><span class="p">(),</span> +</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <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">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Data-Type-Conversions/TRYCAST</span> +</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="s2">"TRYCAST"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">[</span><span class="s2">"TRY_CAST"</span><span class="p">],</span> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="s2">"RANGE_N"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_rangen</span><span class="p">(),</span> +</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="s2">"TRANSLATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> +</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="p">}</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="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</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-135"><a href="#L-135"><span class="linenos">135</span></a> <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="k">def</span> <span class="nf">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-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="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">):</span> +</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected USING in TRANSLATE"</span><span class="p">)</span> +</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> +</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHARSET_TRANSLATORS</span><span class="p">):</span> +</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="n">charset_split</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"_TO_"</span><span class="p">)</span> +</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">charset_split</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> +</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected a character set translator after USING in TRANSLATE"</span><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="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> +</span><span id="L-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="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="k">def</span> <span class="nf">_parse_update</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">:</span> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> +</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> +</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">joins</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">)</span> +</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="p">},</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <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">_parse_rangen</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">)</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">each</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"EACH"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RangeN</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">each</span><span class="o">=</span><span class="n">each</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">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos">184</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">GEOMETRY</span><span class="p">:</span> <span class="s2">"ST_GEOMETRY"</span><span class="p">,</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="p">}</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> +</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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_INDEX</span><span class="p">,</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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_CREATE</span><span class="p">,</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="p">}</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pow</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">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"**"</span><span class="p">),</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <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 class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">]</span> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="p">),</span> +</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</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">"DATABASE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="p">}</span> +</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span> <span class="ow">and</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">"format"</span><span class="p">):</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="c1"># We don't actually want to print the unknown type in CAST(<value> AS FORMAT <format>)</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> +</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> +</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY"</span><span class="p">)</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> +</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> SAMPLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="k">def</span> <span class="nf">partitionedbyproperty_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">PartitionedByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> +</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="k">def</span> <span class="nf">update_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">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"MOD"</span><span class="p">)</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="n">type_sql</span> <span class="o">=</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-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="n">prefix_sql</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">"prefix"</span><span class="p">)</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SYSUDTLIB.</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">prefix_sql</span> <span class="k">else</span> <span class="n">type_sql</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="k">def</span> <span class="nf">rangen_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">RangeN</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">)</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" EACH </span><span class="si">{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">each_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RANGE_N(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"TABLE"</span> <span class="ow">and</span> <span class="n">locations</span><span class="o">.</span><span class="n">get</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_NAME</span><span class="p">):</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="n">this_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="n">this_properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">locations</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_NAME</span><span class="p">]),</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="p">)</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="n">this_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this_name</span><span class="si">}{</span><span class="n">this_properties</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this_schema</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">locations</span><span class="p">)</span> </span></pre></div> @@ -586,198 +590,199 @@ </span><span id="Teradata-75"><a href="#Teradata-75"><span class="linenos"> 75</span></a> </span><span id="Teradata-76"><a href="#Teradata-76"><span class="linenos"> 76</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> </span><span id="Teradata-77"><a href="#Teradata-77"><span class="linenos"> 77</span></a> <span class="n">TABLESAMPLE_CSV</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata-78"><a href="#Teradata-78"><span class="linenos"> 78</span></a> -</span><span id="Teradata-79"><a href="#Teradata-79"><span class="linenos"> 79</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-80"><a href="#Teradata-80"><span class="linenos"> 80</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata-81"><a href="#Teradata-81"><span class="linenos"> 81</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> -</span><span id="Teradata-82"><a href="#Teradata-82"><span class="linenos"> 82</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-83"><a href="#Teradata-83"><span class="linenos"> 83</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> -</span><span id="Teradata-84"><a href="#Teradata-84"><span class="linenos"> 84</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-85"><a href="#Teradata-85"><span class="linenos"> 85</span></a> <span class="s2">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-86"><a href="#Teradata-86"><span class="linenos"> 86</span></a> <span class="s2">"KANJI1_KANJISJIS_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-87"><a href="#Teradata-87"><span class="linenos"> 87</span></a> <span class="s2">"KANJI1_SBC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-88"><a href="#Teradata-88"><span class="linenos"> 88</span></a> <span class="s2">"KANJISJIS_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="Teradata-89"><a href="#Teradata-89"><span class="linenos"> 89</span></a> <span class="s2">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> -</span><span id="Teradata-90"><a href="#Teradata-90"><span class="linenos"> 90</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-91"><a href="#Teradata-91"><span class="linenos"> 91</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="Teradata-92"><a href="#Teradata-92"><span class="linenos"> 92</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata-93"><a href="#Teradata-93"><span class="linenos"> 93</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-94"><a href="#Teradata-94"><span class="linenos"> 94</span></a> <span class="s2">"LOCALE_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-95"><a href="#Teradata-95"><span class="linenos"> 95</span></a> <span class="s2">"UNICODE_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="Teradata-96"><a href="#Teradata-96"><span class="linenos"> 96</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_PadGraphic"</span><span class="p">,</span> -</span><span id="Teradata-97"><a href="#Teradata-97"><span class="linenos"> 97</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_VarGraphic"</span><span class="p">,</span> -</span><span id="Teradata-98"><a href="#Teradata-98"><span class="linenos"> 98</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEBCDIC"</span><span class="p">,</span> -</span><span id="Teradata-99"><a href="#Teradata-99"><span class="linenos"> 99</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEUC"</span><span class="p">,</span> -</span><span id="Teradata-100"><a href="#Teradata-100"><span class="linenos">100</span></a> <span class="s2">"UNICODE_TO_KANJI1_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata-101"><a href="#Teradata-101"><span class="linenos">101</span></a> <span class="s2">"UNICODE_TO_KANJI1_SBC"</span><span class="p">,</span> -</span><span id="Teradata-102"><a href="#Teradata-102"><span class="linenos">102</span></a> <span class="s2">"UNICODE_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata-103"><a href="#Teradata-103"><span class="linenos">103</span></a> <span class="s2">"UNICODE_TO_LATIN"</span><span class="p">,</span> -</span><span id="Teradata-104"><a href="#Teradata-104"><span class="linenos">104</span></a> <span class="s2">"UNICODE_TO_LOCALE"</span><span class="p">,</span> -</span><span id="Teradata-105"><a href="#Teradata-105"><span class="linenos">105</span></a> <span class="s2">"UNICODE_TO_UNICODE_FoldSpace"</span><span class="p">,</span> -</span><span id="Teradata-106"><a href="#Teradata-106"><span class="linenos">106</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> -</span><span id="Teradata-107"><a href="#Teradata-107"><span class="linenos">107</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> -</span><span id="Teradata-108"><a href="#Teradata-108"><span class="linenos">108</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> -</span><span id="Teradata-109"><a href="#Teradata-109"><span class="linenos">109</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> -</span><span id="Teradata-110"><a href="#Teradata-110"><span class="linenos">110</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> -</span><span id="Teradata-111"><a href="#Teradata-111"><span class="linenos">111</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> -</span><span id="Teradata-112"><a href="#Teradata-112"><span class="linenos">112</span></a> <span class="p">}</span> -</span><span id="Teradata-113"><a href="#Teradata-113"><span class="linenos">113</span></a> -</span><span id="Teradata-114"><a href="#Teradata-114"><span class="linenos">114</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">}</span> -</span><span id="Teradata-115"><a href="#Teradata-115"><span class="linenos">115</span></a> <span class="n">FUNC_TOKENS</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">)</span> -</span><span id="Teradata-116"><a href="#Teradata-116"><span class="linenos">116</span></a> -</span><span id="Teradata-117"><a href="#Teradata-117"><span class="linenos">117</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-118"><a href="#Teradata-118"><span class="linenos">118</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> -</span><span id="Teradata-119"><a href="#Teradata-119"><span class="linenos">119</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Teradata-120"><a href="#Teradata-120"><span class="linenos">120</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Teradata-121"><a href="#Teradata-121"><span class="linenos">121</span></a> <span class="p">),</span> -</span><span id="Teradata-122"><a href="#Teradata-122"><span class="linenos">122</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_create</span><span class="p">(),</span> -</span><span id="Teradata-123"><a href="#Teradata-123"><span class="linenos">123</span></a> <span class="p">}</span> -</span><span id="Teradata-124"><a href="#Teradata-124"><span class="linenos">124</span></a> -</span><span id="Teradata-125"><a href="#Teradata-125"><span class="linenos">125</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-126"><a href="#Teradata-126"><span class="linenos">126</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="Teradata-127"><a href="#Teradata-127"><span class="linenos">127</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Data-Type-Conversions/TRYCAST</span> -</span><span id="Teradata-128"><a href="#Teradata-128"><span class="linenos">128</span></a> <span class="s2">"TRYCAST"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">[</span><span class="s2">"TRY_CAST"</span><span class="p">],</span> -</span><span id="Teradata-129"><a href="#Teradata-129"><span class="linenos">129</span></a> <span class="s2">"RANGE_N"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_rangen</span><span class="p">(),</span> -</span><span id="Teradata-130"><a href="#Teradata-130"><span class="linenos">130</span></a> <span class="s2">"TRANSLATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> -</span><span id="Teradata-131"><a href="#Teradata-131"><span class="linenos">131</span></a> <span class="p">}</span> -</span><span id="Teradata-132"><a href="#Teradata-132"><span class="linenos">132</span></a> -</span><span id="Teradata-133"><a href="#Teradata-133"><span class="linenos">133</span></a> <span class="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-134"><a href="#Teradata-134"><span class="linenos">134</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</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="Teradata-135"><a href="#Teradata-135"><span class="linenos">135</span></a> <span class="p">}</span> -</span><span id="Teradata-136"><a href="#Teradata-136"><span class="linenos">136</span></a> -</span><span id="Teradata-137"><a href="#Teradata-137"><span class="linenos">137</span></a> <span class="k">def</span> <span class="nf">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Teradata-138"><a href="#Teradata-138"><span class="linenos">138</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Teradata-139"><a href="#Teradata-139"><span class="linenos">139</span></a> -</span><span id="Teradata-140"><a href="#Teradata-140"><span class="linenos">140</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">):</span> -</span><span id="Teradata-141"><a href="#Teradata-141"><span class="linenos">141</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected USING in TRANSLATE"</span><span class="p">)</span> -</span><span id="Teradata-142"><a href="#Teradata-142"><span class="linenos">142</span></a> -</span><span id="Teradata-143"><a href="#Teradata-143"><span class="linenos">143</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHARSET_TRANSLATORS</span><span class="p">):</span> -</span><span id="Teradata-144"><a href="#Teradata-144"><span class="linenos">144</span></a> <span class="n">charset_split</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"_TO_"</span><span class="p">)</span> -</span><span id="Teradata-145"><a href="#Teradata-145"><span class="linenos">145</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">charset_split</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> -</span><span id="Teradata-146"><a href="#Teradata-146"><span class="linenos">146</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Teradata-147"><a href="#Teradata-147"><span class="linenos">147</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected a character set translator after USING in TRANSLATE"</span><span class="p">)</span> -</span><span id="Teradata-148"><a href="#Teradata-148"><span class="linenos">148</span></a> -</span><span id="Teradata-149"><a href="#Teradata-149"><span class="linenos">149</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> -</span><span id="Teradata-150"><a href="#Teradata-150"><span class="linenos">150</span></a> -</span><span id="Teradata-151"><a href="#Teradata-151"><span class="linenos">151</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="Teradata-152"><a href="#Teradata-152"><span class="linenos">152</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> -</span><span id="Teradata-153"><a href="#Teradata-153"><span class="linenos">153</span></a> <span class="k">def</span> <span class="nf">_parse_update</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">:</span> -</span><span id="Teradata-154"><a href="#Teradata-154"><span class="linenos">154</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Teradata-155"><a href="#Teradata-155"><span class="linenos">155</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="Teradata-156"><a href="#Teradata-156"><span class="linenos">156</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> -</span><span id="Teradata-157"><a href="#Teradata-157"><span class="linenos">157</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> -</span><span id="Teradata-158"><a href="#Teradata-158"><span class="linenos">158</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">joins</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Teradata-159"><a href="#Teradata-159"><span class="linenos">159</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">)</span> -</span><span id="Teradata-160"><a href="#Teradata-160"><span class="linenos">160</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> -</span><span id="Teradata-161"><a href="#Teradata-161"><span class="linenos">161</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> -</span><span id="Teradata-162"><a href="#Teradata-162"><span class="linenos">162</span></a> <span class="p">},</span> -</span><span id="Teradata-163"><a href="#Teradata-163"><span class="linenos">163</span></a> <span class="p">)</span> -</span><span id="Teradata-164"><a href="#Teradata-164"><span class="linenos">164</span></a> -</span><span id="Teradata-165"><a href="#Teradata-165"><span class="linenos">165</span></a> <span class="k">def</span> <span class="nf">_parse_rangen</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Teradata-166"><a href="#Teradata-166"><span class="linenos">166</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Teradata-167"><a href="#Teradata-167"><span class="linenos">167</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">)</span> -</span><span id="Teradata-168"><a href="#Teradata-168"><span class="linenos">168</span></a> -</span><span id="Teradata-169"><a href="#Teradata-169"><span class="linenos">169</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Teradata-170"><a href="#Teradata-170"><span class="linenos">170</span></a> <span class="n">each</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"EACH"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Teradata-171"><a href="#Teradata-171"><span class="linenos">171</span></a> -</span><span id="Teradata-172"><a href="#Teradata-172"><span class="linenos">172</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RangeN</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">each</span><span class="o">=</span><span class="n">each</span><span class="p">)</span> -</span><span id="Teradata-173"><a href="#Teradata-173"><span class="linenos">173</span></a> -</span><span id="Teradata-174"><a href="#Teradata-174"><span class="linenos">174</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="Teradata-175"><a href="#Teradata-175"><span class="linenos">175</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata-176"><a href="#Teradata-176"><span class="linenos">176</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-177"><a href="#Teradata-177"><span class="linenos">177</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-178"><a href="#Teradata-178"><span class="linenos">178</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-179"><a href="#Teradata-179"><span class="linenos">179</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> -</span><span id="Teradata-180"><a href="#Teradata-180"><span class="linenos">180</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-181"><a href="#Teradata-181"><span class="linenos">181</span></a> -</span><span id="Teradata-182"><a href="#Teradata-182"><span class="linenos">182</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-183"><a href="#Teradata-183"><span class="linenos">183</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="Teradata-184"><a href="#Teradata-184"><span class="linenos">184</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">GEOMETRY</span><span class="p">:</span> <span class="s2">"ST_GEOMETRY"</span><span class="p">,</span> -</span><span id="Teradata-185"><a href="#Teradata-185"><span class="linenos">185</span></a> <span class="p">}</span> -</span><span id="Teradata-186"><a href="#Teradata-186"><span class="linenos">186</span></a> -</span><span id="Teradata-187"><a href="#Teradata-187"><span class="linenos">187</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-188"><a href="#Teradata-188"><span class="linenos">188</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Teradata-189"><a href="#Teradata-189"><span class="linenos">189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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_INDEX</span><span class="p">,</span> -</span><span id="Teradata-190"><a href="#Teradata-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="Teradata-191"><a href="#Teradata-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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_CREATE</span><span class="p">,</span> -</span><span id="Teradata-192"><a href="#Teradata-192"><span class="linenos">192</span></a> <span class="p">}</span> -</span><span id="Teradata-193"><a href="#Teradata-193"><span class="linenos">193</span></a> -</span><span id="Teradata-194"><a href="#Teradata-194"><span class="linenos">194</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-195"><a href="#Teradata-195"><span class="linenos">195</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="Teradata-196"><a href="#Teradata-196"><span class="linenos">196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> -</span><span id="Teradata-197"><a href="#Teradata-197"><span class="linenos">197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> -</span><span id="Teradata-198"><a href="#Teradata-198"><span class="linenos">198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="Teradata-199"><a href="#Teradata-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="Teradata-200"><a href="#Teradata-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pow</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">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"**"</span><span class="p">),</span> -</span><span id="Teradata-201"><a href="#Teradata-201"><span class="linenos">201</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Teradata-202"><a href="#Teradata-202"><span class="linenos">202</span></a> <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 class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">]</span> -</span><span id="Teradata-203"><a href="#Teradata-203"><span class="linenos">203</span></a> <span class="p">),</span> -</span><span id="Teradata-204"><a href="#Teradata-204"><span class="linenos">204</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Teradata-205"><a href="#Teradata-205"><span class="linenos">205</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Teradata-206"><a href="#Teradata-206"><span class="linenos">206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Teradata-207"><a href="#Teradata-207"><span class="linenos">207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</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">"DATABASE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Teradata-208"><a href="#Teradata-208"><span class="linenos">208</span></a> <span class="p">}</span> -</span><span id="Teradata-209"><a href="#Teradata-209"><span class="linenos">209</span></a> -</span><span id="Teradata-210"><a href="#Teradata-210"><span class="linenos">210</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-211"><a href="#Teradata-211"><span class="linenos">211</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span> <span class="ow">and</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">"format"</span><span class="p">):</span> -</span><span id="Teradata-212"><a href="#Teradata-212"><span class="linenos">212</span></a> <span class="c1"># We don't actually want to print the unknown type in CAST(<value> AS FORMAT <format>)</span> -</span><span id="Teradata-213"><a href="#Teradata-213"><span class="linenos">213</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> -</span><span id="Teradata-214"><a href="#Teradata-214"><span class="linenos">214</span></a> -</span><span id="Teradata-215"><a href="#Teradata-215"><span class="linenos">215</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> -</span><span id="Teradata-216"><a href="#Teradata-216"><span class="linenos">216</span></a> -</span><span id="Teradata-217"><a href="#Teradata-217"><span class="linenos">217</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-218"><a href="#Teradata-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY"</span><span class="p">)</span> -</span><span id="Teradata-219"><a href="#Teradata-219"><span class="linenos">219</span></a> -</span><span id="Teradata-220"><a href="#Teradata-220"><span class="linenos">220</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Teradata-221"><a href="#Teradata-221"><span class="linenos">221</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Teradata-222"><a href="#Teradata-222"><span class="linenos">222</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> -</span><span id="Teradata-223"><a href="#Teradata-223"><span class="linenos">223</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> -</span><span id="Teradata-224"><a href="#Teradata-224"><span class="linenos">224</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Teradata-225"><a href="#Teradata-225"><span class="linenos">225</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-226"><a href="#Teradata-226"><span class="linenos">226</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> SAMPLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata-227"><a href="#Teradata-227"><span class="linenos">227</span></a> -</span><span id="Teradata-228"><a href="#Teradata-228"><span class="linenos">228</span></a> <span class="k">def</span> <span class="nf">partitionedbyproperty_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">PartitionedByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-229"><a href="#Teradata-229"><span class="linenos">229</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata-230"><a href="#Teradata-230"><span class="linenos">230</span></a> -</span><span id="Teradata-231"><a href="#Teradata-231"><span class="linenos">231</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="Teradata-232"><a href="#Teradata-232"><span class="linenos">232</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> -</span><span id="Teradata-233"><a href="#Teradata-233"><span class="linenos">233</span></a> <span class="k">def</span> <span class="nf">update_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">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-234"><a href="#Teradata-234"><span class="linenos">234</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Teradata-235"><a href="#Teradata-235"><span class="linenos">235</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> -</span><span id="Teradata-236"><a href="#Teradata-236"><span class="linenos">236</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Teradata-237"><a href="#Teradata-237"><span class="linenos">237</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Teradata-238"><a href="#Teradata-238"><span class="linenos">238</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata-239"><a href="#Teradata-239"><span class="linenos">239</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Teradata-240"><a href="#Teradata-240"><span class="linenos">240</span></a> -</span><span id="Teradata-241"><a href="#Teradata-241"><span class="linenos">241</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-242"><a href="#Teradata-242"><span class="linenos">242</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"MOD"</span><span class="p">)</span> -</span><span id="Teradata-243"><a href="#Teradata-243"><span class="linenos">243</span></a> -</span><span id="Teradata-244"><a href="#Teradata-244"><span class="linenos">244</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-245"><a href="#Teradata-245"><span class="linenos">245</span></a> <span class="n">type_sql</span> <span class="o">=</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="Teradata-246"><a href="#Teradata-246"><span class="linenos">246</span></a> <span class="n">prefix_sql</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">"prefix"</span><span class="p">)</span> -</span><span id="Teradata-247"><a href="#Teradata-247"><span class="linenos">247</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SYSUDTLIB.</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">prefix_sql</span> <span class="k">else</span> <span class="n">type_sql</span> -</span><span id="Teradata-248"><a href="#Teradata-248"><span class="linenos">248</span></a> -</span><span id="Teradata-249"><a href="#Teradata-249"><span class="linenos">249</span></a> <span class="k">def</span> <span class="nf">rangen_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">RangeN</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-250"><a href="#Teradata-250"><span class="linenos">250</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Teradata-251"><a href="#Teradata-251"><span class="linenos">251</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Teradata-252"><a href="#Teradata-252"><span class="linenos">252</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">)</span> -</span><span id="Teradata-253"><a href="#Teradata-253"><span class="linenos">253</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" EACH </span><span class="si">{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">each_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Teradata-254"><a href="#Teradata-254"><span class="linenos">254</span></a> -</span><span id="Teradata-255"><a href="#Teradata-255"><span class="linenos">255</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RANGE_N(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Teradata-256"><a href="#Teradata-256"><span class="linenos">256</span></a> -</span><span id="Teradata-257"><a href="#Teradata-257"><span class="linenos">257</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-258"><a href="#Teradata-258"><span class="linenos">258</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Teradata-259"><a href="#Teradata-259"><span class="linenos">259</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"TABLE"</span> <span class="ow">and</span> <span class="n">locations</span><span class="o">.</span><span class="n">get</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_NAME</span><span class="p">):</span> -</span><span id="Teradata-260"><a href="#Teradata-260"><span class="linenos">260</span></a> <span class="n">this_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Teradata-261"><a href="#Teradata-261"><span class="linenos">261</span></a> <span class="n">this_properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Teradata-262"><a href="#Teradata-262"><span class="linenos">262</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">locations</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_NAME</span><span class="p">]),</span> -</span><span id="Teradata-263"><a href="#Teradata-263"><span class="linenos">263</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Teradata-264"><a href="#Teradata-264"><span class="linenos">264</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> -</span><span id="Teradata-265"><a href="#Teradata-265"><span class="linenos">265</span></a> <span class="p">)</span> -</span><span id="Teradata-266"><a href="#Teradata-266"><span class="linenos">266</span></a> <span class="n">this_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Teradata-267"><a href="#Teradata-267"><span class="linenos">267</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this_name</span><span class="si">}{</span><span class="n">this_properties</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this_schema</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata-268"><a href="#Teradata-268"><span class="linenos">268</span></a> -</span><span id="Teradata-269"><a href="#Teradata-269"><span class="linenos">269</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">locations</span><span class="p">)</span> +</span><span id="Teradata-78"><a href="#Teradata-78"><span class="linenos"> 78</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-79"><a href="#Teradata-79"><span class="linenos"> 79</span></a> +</span><span id="Teradata-80"><a href="#Teradata-80"><span class="linenos"> 80</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-81"><a href="#Teradata-81"><span class="linenos"> 81</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata-82"><a href="#Teradata-82"><span class="linenos"> 82</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata-83"><a href="#Teradata-83"><span class="linenos"> 83</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-84"><a href="#Teradata-84"><span class="linenos"> 84</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> +</span><span id="Teradata-85"><a href="#Teradata-85"><span class="linenos"> 85</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-86"><a href="#Teradata-86"><span class="linenos"> 86</span></a> <span class="s2">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-87"><a href="#Teradata-87"><span class="linenos"> 87</span></a> <span class="s2">"KANJI1_KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-88"><a href="#Teradata-88"><span class="linenos"> 88</span></a> <span class="s2">"KANJI1_SBC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-89"><a href="#Teradata-89"><span class="linenos"> 89</span></a> <span class="s2">"KANJISJIS_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata-90"><a href="#Teradata-90"><span class="linenos"> 90</span></a> <span class="s2">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata-91"><a href="#Teradata-91"><span class="linenos"> 91</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-92"><a href="#Teradata-92"><span class="linenos"> 92</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata-93"><a href="#Teradata-93"><span class="linenos"> 93</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata-94"><a href="#Teradata-94"><span class="linenos"> 94</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-95"><a href="#Teradata-95"><span class="linenos"> 95</span></a> <span class="s2">"LOCALE_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-96"><a href="#Teradata-96"><span class="linenos"> 96</span></a> <span class="s2">"UNICODE_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata-97"><a href="#Teradata-97"><span class="linenos"> 97</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_PadGraphic"</span><span class="p">,</span> +</span><span id="Teradata-98"><a href="#Teradata-98"><span class="linenos"> 98</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_VarGraphic"</span><span class="p">,</span> +</span><span id="Teradata-99"><a href="#Teradata-99"><span class="linenos"> 99</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEBCDIC"</span><span class="p">,</span> +</span><span id="Teradata-100"><a href="#Teradata-100"><span class="linenos">100</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEUC"</span><span class="p">,</span> +</span><span id="Teradata-101"><a href="#Teradata-101"><span class="linenos">101</span></a> <span class="s2">"UNICODE_TO_KANJI1_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata-102"><a href="#Teradata-102"><span class="linenos">102</span></a> <span class="s2">"UNICODE_TO_KANJI1_SBC"</span><span class="p">,</span> +</span><span id="Teradata-103"><a href="#Teradata-103"><span class="linenos">103</span></a> <span class="s2">"UNICODE_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata-104"><a href="#Teradata-104"><span class="linenos">104</span></a> <span class="s2">"UNICODE_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata-105"><a href="#Teradata-105"><span class="linenos">105</span></a> <span class="s2">"UNICODE_TO_LOCALE"</span><span class="p">,</span> +</span><span id="Teradata-106"><a href="#Teradata-106"><span class="linenos">106</span></a> <span class="s2">"UNICODE_TO_UNICODE_FoldSpace"</span><span class="p">,</span> +</span><span id="Teradata-107"><a href="#Teradata-107"><span class="linenos">107</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> +</span><span id="Teradata-108"><a href="#Teradata-108"><span class="linenos">108</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> +</span><span id="Teradata-109"><a href="#Teradata-109"><span class="linenos">109</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> +</span><span id="Teradata-110"><a href="#Teradata-110"><span class="linenos">110</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> +</span><span id="Teradata-111"><a href="#Teradata-111"><span class="linenos">111</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> +</span><span id="Teradata-112"><a href="#Teradata-112"><span class="linenos">112</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> +</span><span id="Teradata-113"><a href="#Teradata-113"><span class="linenos">113</span></a> <span class="p">}</span> +</span><span id="Teradata-114"><a href="#Teradata-114"><span class="linenos">114</span></a> +</span><span id="Teradata-115"><a href="#Teradata-115"><span class="linenos">115</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">}</span> +</span><span id="Teradata-116"><a href="#Teradata-116"><span class="linenos">116</span></a> <span class="n">FUNC_TOKENS</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">)</span> +</span><span id="Teradata-117"><a href="#Teradata-117"><span class="linenos">117</span></a> +</span><span id="Teradata-118"><a href="#Teradata-118"><span class="linenos">118</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-119"><a href="#Teradata-119"><span class="linenos">119</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> +</span><span id="Teradata-120"><a href="#Teradata-120"><span class="linenos">120</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Teradata-121"><a href="#Teradata-121"><span class="linenos">121</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Teradata-122"><a href="#Teradata-122"><span class="linenos">122</span></a> <span class="p">),</span> +</span><span id="Teradata-123"><a href="#Teradata-123"><span class="linenos">123</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_create</span><span class="p">(),</span> +</span><span id="Teradata-124"><a href="#Teradata-124"><span class="linenos">124</span></a> <span class="p">}</span> +</span><span id="Teradata-125"><a href="#Teradata-125"><span class="linenos">125</span></a> +</span><span id="Teradata-126"><a href="#Teradata-126"><span class="linenos">126</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-127"><a href="#Teradata-127"><span class="linenos">127</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="Teradata-128"><a href="#Teradata-128"><span class="linenos">128</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Data-Type-Conversions/TRYCAST</span> +</span><span id="Teradata-129"><a href="#Teradata-129"><span class="linenos">129</span></a> <span class="s2">"TRYCAST"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">[</span><span class="s2">"TRY_CAST"</span><span class="p">],</span> +</span><span id="Teradata-130"><a href="#Teradata-130"><span class="linenos">130</span></a> <span class="s2">"RANGE_N"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_rangen</span><span class="p">(),</span> +</span><span id="Teradata-131"><a href="#Teradata-131"><span class="linenos">131</span></a> <span class="s2">"TRANSLATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> +</span><span id="Teradata-132"><a href="#Teradata-132"><span class="linenos">132</span></a> <span class="p">}</span> +</span><span id="Teradata-133"><a href="#Teradata-133"><span class="linenos">133</span></a> +</span><span id="Teradata-134"><a href="#Teradata-134"><span class="linenos">134</span></a> <span class="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-135"><a href="#Teradata-135"><span class="linenos">135</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</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="Teradata-136"><a href="#Teradata-136"><span class="linenos">136</span></a> <span class="p">}</span> +</span><span id="Teradata-137"><a href="#Teradata-137"><span class="linenos">137</span></a> +</span><span id="Teradata-138"><a href="#Teradata-138"><span class="linenos">138</span></a> <span class="k">def</span> <span class="nf">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Teradata-139"><a href="#Teradata-139"><span class="linenos">139</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Teradata-140"><a href="#Teradata-140"><span class="linenos">140</span></a> +</span><span id="Teradata-141"><a href="#Teradata-141"><span class="linenos">141</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">):</span> +</span><span id="Teradata-142"><a href="#Teradata-142"><span class="linenos">142</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected USING in TRANSLATE"</span><span class="p">)</span> +</span><span id="Teradata-143"><a href="#Teradata-143"><span class="linenos">143</span></a> +</span><span id="Teradata-144"><a href="#Teradata-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHARSET_TRANSLATORS</span><span class="p">):</span> +</span><span id="Teradata-145"><a href="#Teradata-145"><span class="linenos">145</span></a> <span class="n">charset_split</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"_TO_"</span><span class="p">)</span> +</span><span id="Teradata-146"><a href="#Teradata-146"><span class="linenos">146</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">charset_split</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> +</span><span id="Teradata-147"><a href="#Teradata-147"><span class="linenos">147</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Teradata-148"><a href="#Teradata-148"><span class="linenos">148</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected a character set translator after USING in TRANSLATE"</span><span class="p">)</span> +</span><span id="Teradata-149"><a href="#Teradata-149"><span class="linenos">149</span></a> +</span><span id="Teradata-150"><a href="#Teradata-150"><span class="linenos">150</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> +</span><span id="Teradata-151"><a href="#Teradata-151"><span class="linenos">151</span></a> +</span><span id="Teradata-152"><a href="#Teradata-152"><span class="linenos">152</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="Teradata-153"><a href="#Teradata-153"><span class="linenos">153</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> +</span><span id="Teradata-154"><a href="#Teradata-154"><span class="linenos">154</span></a> <span class="k">def</span> <span class="nf">_parse_update</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">:</span> +</span><span id="Teradata-155"><a href="#Teradata-155"><span class="linenos">155</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Teradata-156"><a href="#Teradata-156"><span class="linenos">156</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="Teradata-157"><a href="#Teradata-157"><span class="linenos">157</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> +</span><span id="Teradata-158"><a href="#Teradata-158"><span class="linenos">158</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> +</span><span id="Teradata-159"><a href="#Teradata-159"><span class="linenos">159</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">joins</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Teradata-160"><a href="#Teradata-160"><span class="linenos">160</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">)</span> +</span><span id="Teradata-161"><a href="#Teradata-161"><span class="linenos">161</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> +</span><span id="Teradata-162"><a href="#Teradata-162"><span class="linenos">162</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> +</span><span id="Teradata-163"><a href="#Teradata-163"><span class="linenos">163</span></a> <span class="p">},</span> +</span><span id="Teradata-164"><a href="#Teradata-164"><span class="linenos">164</span></a> <span class="p">)</span> +</span><span id="Teradata-165"><a href="#Teradata-165"><span class="linenos">165</span></a> +</span><span id="Teradata-166"><a href="#Teradata-166"><span class="linenos">166</span></a> <span class="k">def</span> <span class="nf">_parse_rangen</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Teradata-167"><a href="#Teradata-167"><span class="linenos">167</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Teradata-168"><a href="#Teradata-168"><span class="linenos">168</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">)</span> +</span><span id="Teradata-169"><a href="#Teradata-169"><span class="linenos">169</span></a> +</span><span id="Teradata-170"><a href="#Teradata-170"><span class="linenos">170</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Teradata-171"><a href="#Teradata-171"><span class="linenos">171</span></a> <span class="n">each</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"EACH"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Teradata-172"><a href="#Teradata-172"><span class="linenos">172</span></a> +</span><span id="Teradata-173"><a href="#Teradata-173"><span class="linenos">173</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RangeN</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">each</span><span class="o">=</span><span class="n">each</span><span class="p">)</span> +</span><span id="Teradata-174"><a href="#Teradata-174"><span class="linenos">174</span></a> +</span><span id="Teradata-175"><a href="#Teradata-175"><span class="linenos">175</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="Teradata-176"><a href="#Teradata-176"><span class="linenos">176</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Teradata-177"><a href="#Teradata-177"><span class="linenos">177</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-178"><a href="#Teradata-178"><span class="linenos">178</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-179"><a href="#Teradata-179"><span class="linenos">179</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-180"><a href="#Teradata-180"><span class="linenos">180</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> +</span><span id="Teradata-181"><a href="#Teradata-181"><span class="linenos">181</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-182"><a href="#Teradata-182"><span class="linenos">182</span></a> +</span><span id="Teradata-183"><a href="#Teradata-183"><span class="linenos">183</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-184"><a href="#Teradata-184"><span class="linenos">184</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="Teradata-185"><a href="#Teradata-185"><span class="linenos">185</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">GEOMETRY</span><span class="p">:</span> <span class="s2">"ST_GEOMETRY"</span><span class="p">,</span> +</span><span id="Teradata-186"><a href="#Teradata-186"><span class="linenos">186</span></a> <span class="p">}</span> +</span><span id="Teradata-187"><a href="#Teradata-187"><span class="linenos">187</span></a> +</span><span id="Teradata-188"><a href="#Teradata-188"><span class="linenos">188</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-189"><a href="#Teradata-189"><span class="linenos">189</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Teradata-190"><a href="#Teradata-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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_INDEX</span><span class="p">,</span> +</span><span id="Teradata-191"><a href="#Teradata-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="Teradata-192"><a href="#Teradata-192"><span class="linenos">192</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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_CREATE</span><span class="p">,</span> +</span><span id="Teradata-193"><a href="#Teradata-193"><span class="linenos">193</span></a> <span class="p">}</span> +</span><span id="Teradata-194"><a href="#Teradata-194"><span class="linenos">194</span></a> +</span><span id="Teradata-195"><a href="#Teradata-195"><span class="linenos">195</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-196"><a href="#Teradata-196"><span class="linenos">196</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="Teradata-197"><a href="#Teradata-197"><span class="linenos">197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> +</span><span id="Teradata-198"><a href="#Teradata-198"><span class="linenos">198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> +</span><span id="Teradata-199"><a href="#Teradata-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="Teradata-200"><a href="#Teradata-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="Teradata-201"><a href="#Teradata-201"><span class="linenos">201</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pow</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">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"**"</span><span class="p">),</span> +</span><span id="Teradata-202"><a href="#Teradata-202"><span class="linenos">202</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Teradata-203"><a href="#Teradata-203"><span class="linenos">203</span></a> <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 class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">]</span> +</span><span id="Teradata-204"><a href="#Teradata-204"><span class="linenos">204</span></a> <span class="p">),</span> +</span><span id="Teradata-205"><a href="#Teradata-205"><span class="linenos">205</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Teradata-206"><a href="#Teradata-206"><span class="linenos">206</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Teradata-207"><a href="#Teradata-207"><span class="linenos">207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Teradata-208"><a href="#Teradata-208"><span class="linenos">208</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</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">"DATABASE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Teradata-209"><a href="#Teradata-209"><span class="linenos">209</span></a> <span class="p">}</span> +</span><span id="Teradata-210"><a href="#Teradata-210"><span class="linenos">210</span></a> +</span><span id="Teradata-211"><a href="#Teradata-211"><span class="linenos">211</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-212"><a href="#Teradata-212"><span class="linenos">212</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span> <span class="ow">and</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">"format"</span><span class="p">):</span> +</span><span id="Teradata-213"><a href="#Teradata-213"><span class="linenos">213</span></a> <span class="c1"># We don't actually want to print the unknown type in CAST(<value> AS FORMAT <format>)</span> +</span><span id="Teradata-214"><a href="#Teradata-214"><span class="linenos">214</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> +</span><span id="Teradata-215"><a href="#Teradata-215"><span class="linenos">215</span></a> +</span><span id="Teradata-216"><a href="#Teradata-216"><span class="linenos">216</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> +</span><span id="Teradata-217"><a href="#Teradata-217"><span class="linenos">217</span></a> +</span><span id="Teradata-218"><a href="#Teradata-218"><span class="linenos">218</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-219"><a href="#Teradata-219"><span class="linenos">219</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY"</span><span class="p">)</span> +</span><span id="Teradata-220"><a href="#Teradata-220"><span class="linenos">220</span></a> +</span><span id="Teradata-221"><a href="#Teradata-221"><span class="linenos">221</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="Teradata-222"><a href="#Teradata-222"><span class="linenos">222</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Teradata-223"><a href="#Teradata-223"><span class="linenos">223</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> +</span><span id="Teradata-224"><a href="#Teradata-224"><span class="linenos">224</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> +</span><span id="Teradata-225"><a href="#Teradata-225"><span class="linenos">225</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Teradata-226"><a href="#Teradata-226"><span class="linenos">226</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-227"><a href="#Teradata-227"><span class="linenos">227</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> SAMPLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata-228"><a href="#Teradata-228"><span class="linenos">228</span></a> +</span><span id="Teradata-229"><a href="#Teradata-229"><span class="linenos">229</span></a> <span class="k">def</span> <span class="nf">partitionedbyproperty_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">PartitionedByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-230"><a href="#Teradata-230"><span class="linenos">230</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata-231"><a href="#Teradata-231"><span class="linenos">231</span></a> +</span><span id="Teradata-232"><a href="#Teradata-232"><span class="linenos">232</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="Teradata-233"><a href="#Teradata-233"><span class="linenos">233</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> +</span><span id="Teradata-234"><a href="#Teradata-234"><span class="linenos">234</span></a> <span class="k">def</span> <span class="nf">update_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">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-235"><a href="#Teradata-235"><span class="linenos">235</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Teradata-236"><a href="#Teradata-236"><span class="linenos">236</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> +</span><span id="Teradata-237"><a href="#Teradata-237"><span class="linenos">237</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Teradata-238"><a href="#Teradata-238"><span class="linenos">238</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Teradata-239"><a href="#Teradata-239"><span class="linenos">239</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata-240"><a href="#Teradata-240"><span class="linenos">240</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Teradata-241"><a href="#Teradata-241"><span class="linenos">241</span></a> +</span><span id="Teradata-242"><a href="#Teradata-242"><span class="linenos">242</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-243"><a href="#Teradata-243"><span class="linenos">243</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"MOD"</span><span class="p">)</span> +</span><span id="Teradata-244"><a href="#Teradata-244"><span class="linenos">244</span></a> +</span><span id="Teradata-245"><a href="#Teradata-245"><span class="linenos">245</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-246"><a href="#Teradata-246"><span class="linenos">246</span></a> <span class="n">type_sql</span> <span class="o">=</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="Teradata-247"><a href="#Teradata-247"><span class="linenos">247</span></a> <span class="n">prefix_sql</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">"prefix"</span><span class="p">)</span> +</span><span id="Teradata-248"><a href="#Teradata-248"><span class="linenos">248</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SYSUDTLIB.</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">prefix_sql</span> <span class="k">else</span> <span class="n">type_sql</span> +</span><span id="Teradata-249"><a href="#Teradata-249"><span class="linenos">249</span></a> +</span><span id="Teradata-250"><a href="#Teradata-250"><span class="linenos">250</span></a> <span class="k">def</span> <span class="nf">rangen_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">RangeN</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-251"><a href="#Teradata-251"><span class="linenos">251</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Teradata-252"><a href="#Teradata-252"><span class="linenos">252</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Teradata-253"><a href="#Teradata-253"><span class="linenos">253</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">)</span> +</span><span id="Teradata-254"><a href="#Teradata-254"><span class="linenos">254</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" EACH </span><span class="si">{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">each_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Teradata-255"><a href="#Teradata-255"><span class="linenos">255</span></a> +</span><span id="Teradata-256"><a href="#Teradata-256"><span class="linenos">256</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RANGE_N(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Teradata-257"><a href="#Teradata-257"><span class="linenos">257</span></a> +</span><span id="Teradata-258"><a href="#Teradata-258"><span class="linenos">258</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-259"><a href="#Teradata-259"><span class="linenos">259</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Teradata-260"><a href="#Teradata-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"TABLE"</span> <span class="ow">and</span> <span class="n">locations</span><span class="o">.</span><span class="n">get</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_NAME</span><span class="p">):</span> +</span><span id="Teradata-261"><a href="#Teradata-261"><span class="linenos">261</span></a> <span class="n">this_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Teradata-262"><a href="#Teradata-262"><span class="linenos">262</span></a> <span class="n">this_properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Teradata-263"><a href="#Teradata-263"><span class="linenos">263</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">locations</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_NAME</span><span class="p">]),</span> +</span><span id="Teradata-264"><a href="#Teradata-264"><span class="linenos">264</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Teradata-265"><a href="#Teradata-265"><span class="linenos">265</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> +</span><span id="Teradata-266"><a href="#Teradata-266"><span class="linenos">266</span></a> <span class="p">)</span> +</span><span id="Teradata-267"><a href="#Teradata-267"><span class="linenos">267</span></a> <span class="n">this_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Teradata-268"><a href="#Teradata-268"><span class="linenos">268</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this_name</span><span class="si">}{</span><span class="n">this_properties</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this_schema</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata-269"><a href="#Teradata-269"><span class="linenos">269</span></a> +</span><span id="Teradata-270"><a href="#Teradata-270"><span class="linenos">270</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">locations</span><span class="p">)</span> </span></pre></div> @@ -1241,101 +1246,102 @@ True means <code>a / b</code> is integer division if both <code>a</code> and <co <a class="headerlink" href="#Teradata.Parser"></a> <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Parser-76"><a href="#Teradata.Parser-76"><span class="linenos"> 76</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> </span><span id="Teradata.Parser-77"><a href="#Teradata.Parser-77"><span class="linenos"> 77</span></a> <span class="n">TABLESAMPLE_CSV</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata.Parser-78"><a href="#Teradata.Parser-78"><span class="linenos"> 78</span></a> -</span><span id="Teradata.Parser-79"><a href="#Teradata.Parser-79"><span class="linenos"> 79</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Parser-80"><a href="#Teradata.Parser-80"><span class="linenos"> 80</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata.Parser-81"><a href="#Teradata.Parser-81"><span class="linenos"> 81</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> -</span><span id="Teradata.Parser-82"><a href="#Teradata.Parser-82"><span class="linenos"> 82</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata.Parser-83"><a href="#Teradata.Parser-83"><span class="linenos"> 83</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> -</span><span id="Teradata.Parser-84"><a href="#Teradata.Parser-84"><span class="linenos"> 84</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata.Parser-85"><a href="#Teradata.Parser-85"><span class="linenos"> 85</span></a> <span class="s2">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata.Parser-86"><a href="#Teradata.Parser-86"><span class="linenos"> 86</span></a> <span class="s2">"KANJI1_KANJISJIS_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata.Parser-87"><a href="#Teradata.Parser-87"><span class="linenos"> 87</span></a> <span class="s2">"KANJI1_SBC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata.Parser-88"><a href="#Teradata.Parser-88"><span class="linenos"> 88</span></a> <span class="s2">"KANJISJIS_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-89"><a href="#Teradata.Parser-89"><span class="linenos"> 89</span></a> <span class="s2">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> -</span><span id="Teradata.Parser-90"><a href="#Teradata.Parser-90"><span class="linenos"> 90</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata.Parser-91"><a href="#Teradata.Parser-91"><span class="linenos"> 91</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-92"><a href="#Teradata.Parser-92"><span class="linenos"> 92</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata.Parser-93"><a href="#Teradata.Parser-93"><span class="linenos"> 93</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata.Parser-94"><a href="#Teradata.Parser-94"><span class="linenos"> 94</span></a> <span class="s2">"LOCALE_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata.Parser-95"><a href="#Teradata.Parser-95"><span class="linenos"> 95</span></a> <span class="s2">"UNICODE_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-96"><a href="#Teradata.Parser-96"><span class="linenos"> 96</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_PadGraphic"</span><span class="p">,</span> -</span><span id="Teradata.Parser-97"><a href="#Teradata.Parser-97"><span class="linenos"> 97</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_VarGraphic"</span><span class="p">,</span> -</span><span id="Teradata.Parser-98"><a href="#Teradata.Parser-98"><span class="linenos"> 98</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEBCDIC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-99"><a href="#Teradata.Parser-99"><span class="linenos"> 99</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEUC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-100"><a href="#Teradata.Parser-100"><span class="linenos">100</span></a> <span class="s2">"UNICODE_TO_KANJI1_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata.Parser-101"><a href="#Teradata.Parser-101"><span class="linenos">101</span></a> <span class="s2">"UNICODE_TO_KANJI1_SBC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-102"><a href="#Teradata.Parser-102"><span class="linenos">102</span></a> <span class="s2">"UNICODE_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata.Parser-103"><a href="#Teradata.Parser-103"><span class="linenos">103</span></a> <span class="s2">"UNICODE_TO_LATIN"</span><span class="p">,</span> -</span><span id="Teradata.Parser-104"><a href="#Teradata.Parser-104"><span class="linenos">104</span></a> <span class="s2">"UNICODE_TO_LOCALE"</span><span class="p">,</span> -</span><span id="Teradata.Parser-105"><a href="#Teradata.Parser-105"><span class="linenos">105</span></a> <span class="s2">"UNICODE_TO_UNICODE_FoldSpace"</span><span class="p">,</span> -</span><span id="Teradata.Parser-106"><a href="#Teradata.Parser-106"><span class="linenos">106</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> -</span><span id="Teradata.Parser-107"><a href="#Teradata.Parser-107"><span class="linenos">107</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> -</span><span id="Teradata.Parser-108"><a href="#Teradata.Parser-108"><span class="linenos">108</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-109"><a href="#Teradata.Parser-109"><span class="linenos">109</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> -</span><span id="Teradata.Parser-110"><a href="#Teradata.Parser-110"><span class="linenos">110</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-111"><a href="#Teradata.Parser-111"><span class="linenos">111</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> -</span><span id="Teradata.Parser-112"><a href="#Teradata.Parser-112"><span class="linenos">112</span></a> <span class="p">}</span> -</span><span id="Teradata.Parser-113"><a href="#Teradata.Parser-113"><span class="linenos">113</span></a> -</span><span id="Teradata.Parser-114"><a href="#Teradata.Parser-114"><span class="linenos">114</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">}</span> -</span><span id="Teradata.Parser-115"><a href="#Teradata.Parser-115"><span class="linenos">115</span></a> <span class="n">FUNC_TOKENS</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">)</span> -</span><span id="Teradata.Parser-116"><a href="#Teradata.Parser-116"><span class="linenos">116</span></a> -</span><span id="Teradata.Parser-117"><a href="#Teradata.Parser-117"><span class="linenos">117</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Parser-118"><a href="#Teradata.Parser-118"><span class="linenos">118</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> -</span><span id="Teradata.Parser-119"><a href="#Teradata.Parser-119"><span class="linenos">119</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Teradata.Parser-120"><a href="#Teradata.Parser-120"><span class="linenos">120</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Teradata.Parser-121"><a href="#Teradata.Parser-121"><span class="linenos">121</span></a> <span class="p">),</span> -</span><span id="Teradata.Parser-122"><a href="#Teradata.Parser-122"><span class="linenos">122</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_create</span><span class="p">(),</span> -</span><span id="Teradata.Parser-123"><a href="#Teradata.Parser-123"><span class="linenos">123</span></a> <span class="p">}</span> -</span><span id="Teradata.Parser-124"><a href="#Teradata.Parser-124"><span class="linenos">124</span></a> -</span><span id="Teradata.Parser-125"><a href="#Teradata.Parser-125"><span class="linenos">125</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Parser-126"><a href="#Teradata.Parser-126"><span class="linenos">126</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="Teradata.Parser-127"><a href="#Teradata.Parser-127"><span class="linenos">127</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Data-Type-Conversions/TRYCAST</span> -</span><span id="Teradata.Parser-128"><a href="#Teradata.Parser-128"><span class="linenos">128</span></a> <span class="s2">"TRYCAST"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">[</span><span class="s2">"TRY_CAST"</span><span class="p">],</span> -</span><span id="Teradata.Parser-129"><a href="#Teradata.Parser-129"><span class="linenos">129</span></a> <span class="s2">"RANGE_N"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_rangen</span><span class="p">(),</span> -</span><span id="Teradata.Parser-130"><a href="#Teradata.Parser-130"><span class="linenos">130</span></a> <span class="s2">"TRANSLATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> -</span><span id="Teradata.Parser-131"><a href="#Teradata.Parser-131"><span class="linenos">131</span></a> <span class="p">}</span> -</span><span id="Teradata.Parser-132"><a href="#Teradata.Parser-132"><span class="linenos">132</span></a> -</span><span id="Teradata.Parser-133"><a href="#Teradata.Parser-133"><span class="linenos">133</span></a> <span class="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Parser-134"><a href="#Teradata.Parser-134"><span class="linenos">134</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</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="Teradata.Parser-135"><a href="#Teradata.Parser-135"><span class="linenos">135</span></a> <span class="p">}</span> -</span><span id="Teradata.Parser-136"><a href="#Teradata.Parser-136"><span class="linenos">136</span></a> -</span><span id="Teradata.Parser-137"><a href="#Teradata.Parser-137"><span class="linenos">137</span></a> <span class="k">def</span> <span class="nf">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Teradata.Parser-138"><a href="#Teradata.Parser-138"><span class="linenos">138</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Teradata.Parser-139"><a href="#Teradata.Parser-139"><span class="linenos">139</span></a> -</span><span id="Teradata.Parser-140"><a href="#Teradata.Parser-140"><span class="linenos">140</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">):</span> -</span><span id="Teradata.Parser-141"><a href="#Teradata.Parser-141"><span class="linenos">141</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected USING in TRANSLATE"</span><span class="p">)</span> -</span><span id="Teradata.Parser-142"><a href="#Teradata.Parser-142"><span class="linenos">142</span></a> -</span><span id="Teradata.Parser-143"><a href="#Teradata.Parser-143"><span class="linenos">143</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHARSET_TRANSLATORS</span><span class="p">):</span> -</span><span id="Teradata.Parser-144"><a href="#Teradata.Parser-144"><span class="linenos">144</span></a> <span class="n">charset_split</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"_TO_"</span><span class="p">)</span> -</span><span id="Teradata.Parser-145"><a href="#Teradata.Parser-145"><span class="linenos">145</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">charset_split</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> -</span><span id="Teradata.Parser-146"><a href="#Teradata.Parser-146"><span class="linenos">146</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Teradata.Parser-147"><a href="#Teradata.Parser-147"><span class="linenos">147</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected a character set translator after USING in TRANSLATE"</span><span class="p">)</span> -</span><span id="Teradata.Parser-148"><a href="#Teradata.Parser-148"><span class="linenos">148</span></a> -</span><span id="Teradata.Parser-149"><a href="#Teradata.Parser-149"><span class="linenos">149</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> -</span><span id="Teradata.Parser-150"><a href="#Teradata.Parser-150"><span class="linenos">150</span></a> -</span><span id="Teradata.Parser-151"><a href="#Teradata.Parser-151"><span class="linenos">151</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="Teradata.Parser-152"><a href="#Teradata.Parser-152"><span class="linenos">152</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> -</span><span id="Teradata.Parser-153"><a href="#Teradata.Parser-153"><span class="linenos">153</span></a> <span class="k">def</span> <span class="nf">_parse_update</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">:</span> -</span><span id="Teradata.Parser-154"><a href="#Teradata.Parser-154"><span class="linenos">154</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Teradata.Parser-155"><a href="#Teradata.Parser-155"><span class="linenos">155</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="Teradata.Parser-156"><a href="#Teradata.Parser-156"><span class="linenos">156</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> -</span><span id="Teradata.Parser-157"><a href="#Teradata.Parser-157"><span class="linenos">157</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> -</span><span id="Teradata.Parser-158"><a href="#Teradata.Parser-158"><span class="linenos">158</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">joins</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Teradata.Parser-159"><a href="#Teradata.Parser-159"><span class="linenos">159</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">)</span> -</span><span id="Teradata.Parser-160"><a href="#Teradata.Parser-160"><span class="linenos">160</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> -</span><span id="Teradata.Parser-161"><a href="#Teradata.Parser-161"><span class="linenos">161</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> -</span><span id="Teradata.Parser-162"><a href="#Teradata.Parser-162"><span class="linenos">162</span></a> <span class="p">},</span> -</span><span id="Teradata.Parser-163"><a href="#Teradata.Parser-163"><span class="linenos">163</span></a> <span class="p">)</span> -</span><span id="Teradata.Parser-164"><a href="#Teradata.Parser-164"><span class="linenos">164</span></a> -</span><span id="Teradata.Parser-165"><a href="#Teradata.Parser-165"><span class="linenos">165</span></a> <span class="k">def</span> <span class="nf">_parse_rangen</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Teradata.Parser-166"><a href="#Teradata.Parser-166"><span class="linenos">166</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Teradata.Parser-167"><a href="#Teradata.Parser-167"><span class="linenos">167</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">)</span> -</span><span id="Teradata.Parser-168"><a href="#Teradata.Parser-168"><span class="linenos">168</span></a> -</span><span id="Teradata.Parser-169"><a href="#Teradata.Parser-169"><span class="linenos">169</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Teradata.Parser-170"><a href="#Teradata.Parser-170"><span class="linenos">170</span></a> <span class="n">each</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"EACH"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Teradata.Parser-171"><a href="#Teradata.Parser-171"><span class="linenos">171</span></a> -</span><span id="Teradata.Parser-172"><a href="#Teradata.Parser-172"><span class="linenos">172</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RangeN</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">each</span><span class="o">=</span><span class="n">each</span><span class="p">)</span> +</span><span id="Teradata.Parser-78"><a href="#Teradata.Parser-78"><span class="linenos"> 78</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata.Parser-79"><a href="#Teradata.Parser-79"><span class="linenos"> 79</span></a> +</span><span id="Teradata.Parser-80"><a href="#Teradata.Parser-80"><span class="linenos"> 80</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Parser-81"><a href="#Teradata.Parser-81"><span class="linenos"> 81</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata.Parser-82"><a href="#Teradata.Parser-82"><span class="linenos"> 82</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata.Parser-83"><a href="#Teradata.Parser-83"><span class="linenos"> 83</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-84"><a href="#Teradata.Parser-84"><span class="linenos"> 84</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> +</span><span id="Teradata.Parser-85"><a href="#Teradata.Parser-85"><span class="linenos"> 85</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-86"><a href="#Teradata.Parser-86"><span class="linenos"> 86</span></a> <span class="s2">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-87"><a href="#Teradata.Parser-87"><span class="linenos"> 87</span></a> <span class="s2">"KANJI1_KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-88"><a href="#Teradata.Parser-88"><span class="linenos"> 88</span></a> <span class="s2">"KANJI1_SBC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-89"><a href="#Teradata.Parser-89"><span class="linenos"> 89</span></a> <span class="s2">"KANJISJIS_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-90"><a href="#Teradata.Parser-90"><span class="linenos"> 90</span></a> <span class="s2">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata.Parser-91"><a href="#Teradata.Parser-91"><span class="linenos"> 91</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-92"><a href="#Teradata.Parser-92"><span class="linenos"> 92</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-93"><a href="#Teradata.Parser-93"><span class="linenos"> 93</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata.Parser-94"><a href="#Teradata.Parser-94"><span class="linenos"> 94</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-95"><a href="#Teradata.Parser-95"><span class="linenos"> 95</span></a> <span class="s2">"LOCALE_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-96"><a href="#Teradata.Parser-96"><span class="linenos"> 96</span></a> <span class="s2">"UNICODE_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-97"><a href="#Teradata.Parser-97"><span class="linenos"> 97</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_PadGraphic"</span><span class="p">,</span> +</span><span id="Teradata.Parser-98"><a href="#Teradata.Parser-98"><span class="linenos"> 98</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_VarGraphic"</span><span class="p">,</span> +</span><span id="Teradata.Parser-99"><a href="#Teradata.Parser-99"><span class="linenos"> 99</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEBCDIC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-100"><a href="#Teradata.Parser-100"><span class="linenos">100</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEUC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-101"><a href="#Teradata.Parser-101"><span class="linenos">101</span></a> <span class="s2">"UNICODE_TO_KANJI1_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata.Parser-102"><a href="#Teradata.Parser-102"><span class="linenos">102</span></a> <span class="s2">"UNICODE_TO_KANJI1_SBC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-103"><a href="#Teradata.Parser-103"><span class="linenos">103</span></a> <span class="s2">"UNICODE_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata.Parser-104"><a href="#Teradata.Parser-104"><span class="linenos">104</span></a> <span class="s2">"UNICODE_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata.Parser-105"><a href="#Teradata.Parser-105"><span class="linenos">105</span></a> <span class="s2">"UNICODE_TO_LOCALE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-106"><a href="#Teradata.Parser-106"><span class="linenos">106</span></a> <span class="s2">"UNICODE_TO_UNICODE_FoldSpace"</span><span class="p">,</span> +</span><span id="Teradata.Parser-107"><a href="#Teradata.Parser-107"><span class="linenos">107</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> +</span><span id="Teradata.Parser-108"><a href="#Teradata.Parser-108"><span class="linenos">108</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> +</span><span id="Teradata.Parser-109"><a href="#Teradata.Parser-109"><span class="linenos">109</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-110"><a href="#Teradata.Parser-110"><span class="linenos">110</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> +</span><span id="Teradata.Parser-111"><a href="#Teradata.Parser-111"><span class="linenos">111</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-112"><a href="#Teradata.Parser-112"><span class="linenos">112</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> +</span><span id="Teradata.Parser-113"><a href="#Teradata.Parser-113"><span class="linenos">113</span></a> <span class="p">}</span> +</span><span id="Teradata.Parser-114"><a href="#Teradata.Parser-114"><span class="linenos">114</span></a> +</span><span id="Teradata.Parser-115"><a href="#Teradata.Parser-115"><span class="linenos">115</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">}</span> +</span><span id="Teradata.Parser-116"><a href="#Teradata.Parser-116"><span class="linenos">116</span></a> <span class="n">FUNC_TOKENS</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">)</span> +</span><span id="Teradata.Parser-117"><a href="#Teradata.Parser-117"><span class="linenos">117</span></a> +</span><span id="Teradata.Parser-118"><a href="#Teradata.Parser-118"><span class="linenos">118</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Parser-119"><a href="#Teradata.Parser-119"><span class="linenos">119</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">,</span> +</span><span id="Teradata.Parser-120"><a href="#Teradata.Parser-120"><span class="linenos">120</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Teradata.Parser-121"><a href="#Teradata.Parser-121"><span class="linenos">121</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Teradata.Parser-122"><a href="#Teradata.Parser-122"><span class="linenos">122</span></a> <span class="p">),</span> +</span><span id="Teradata.Parser-123"><a href="#Teradata.Parser-123"><span class="linenos">123</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_create</span><span class="p">(),</span> +</span><span id="Teradata.Parser-124"><a href="#Teradata.Parser-124"><span class="linenos">124</span></a> <span class="p">}</span> +</span><span id="Teradata.Parser-125"><a href="#Teradata.Parser-125"><span class="linenos">125</span></a> +</span><span id="Teradata.Parser-126"><a href="#Teradata.Parser-126"><span class="linenos">126</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Parser-127"><a href="#Teradata.Parser-127"><span class="linenos">127</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="Teradata.Parser-128"><a href="#Teradata.Parser-128"><span class="linenos">128</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Data-Type-Conversions/TRYCAST</span> +</span><span id="Teradata.Parser-129"><a href="#Teradata.Parser-129"><span class="linenos">129</span></a> <span class="s2">"TRYCAST"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">[</span><span class="s2">"TRY_CAST"</span><span class="p">],</span> +</span><span id="Teradata.Parser-130"><a href="#Teradata.Parser-130"><span class="linenos">130</span></a> <span class="s2">"RANGE_N"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_rangen</span><span class="p">(),</span> +</span><span id="Teradata.Parser-131"><a href="#Teradata.Parser-131"><span class="linenos">131</span></a> <span class="s2">"TRANSLATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> +</span><span id="Teradata.Parser-132"><a href="#Teradata.Parser-132"><span class="linenos">132</span></a> <span class="p">}</span> +</span><span id="Teradata.Parser-133"><a href="#Teradata.Parser-133"><span class="linenos">133</span></a> +</span><span id="Teradata.Parser-134"><a href="#Teradata.Parser-134"><span class="linenos">134</span></a> <span class="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Parser-135"><a href="#Teradata.Parser-135"><span class="linenos">135</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</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="Teradata.Parser-136"><a href="#Teradata.Parser-136"><span class="linenos">136</span></a> <span class="p">}</span> +</span><span id="Teradata.Parser-137"><a href="#Teradata.Parser-137"><span class="linenos">137</span></a> +</span><span id="Teradata.Parser-138"><a href="#Teradata.Parser-138"><span class="linenos">138</span></a> <span class="k">def</span> <span class="nf">_parse_translate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Teradata.Parser-139"><a href="#Teradata.Parser-139"><span class="linenos">139</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Teradata.Parser-140"><a href="#Teradata.Parser-140"><span class="linenos">140</span></a> +</span><span id="Teradata.Parser-141"><a href="#Teradata.Parser-141"><span class="linenos">141</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">):</span> +</span><span id="Teradata.Parser-142"><a href="#Teradata.Parser-142"><span class="linenos">142</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected USING in TRANSLATE"</span><span class="p">)</span> +</span><span id="Teradata.Parser-143"><a href="#Teradata.Parser-143"><span class="linenos">143</span></a> +</span><span id="Teradata.Parser-144"><a href="#Teradata.Parser-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHARSET_TRANSLATORS</span><span class="p">):</span> +</span><span id="Teradata.Parser-145"><a href="#Teradata.Parser-145"><span class="linenos">145</span></a> <span class="n">charset_split</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"_TO_"</span><span class="p">)</span> +</span><span id="Teradata.Parser-146"><a href="#Teradata.Parser-146"><span class="linenos">146</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">charset_split</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> +</span><span id="Teradata.Parser-147"><a href="#Teradata.Parser-147"><span class="linenos">147</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Teradata.Parser-148"><a href="#Teradata.Parser-148"><span class="linenos">148</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected a character set translator after USING in TRANSLATE"</span><span class="p">)</span> +</span><span id="Teradata.Parser-149"><a href="#Teradata.Parser-149"><span class="linenos">149</span></a> +</span><span id="Teradata.Parser-150"><a href="#Teradata.Parser-150"><span class="linenos">150</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> +</span><span id="Teradata.Parser-151"><a href="#Teradata.Parser-151"><span class="linenos">151</span></a> +</span><span id="Teradata.Parser-152"><a href="#Teradata.Parser-152"><span class="linenos">152</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="Teradata.Parser-153"><a href="#Teradata.Parser-153"><span class="linenos">153</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> +</span><span id="Teradata.Parser-154"><a href="#Teradata.Parser-154"><span class="linenos">154</span></a> <span class="k">def</span> <span class="nf">_parse_update</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">:</span> +</span><span id="Teradata.Parser-155"><a href="#Teradata.Parser-155"><span class="linenos">155</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Teradata.Parser-156"><a href="#Teradata.Parser-156"><span class="linenos">156</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="Teradata.Parser-157"><a href="#Teradata.Parser-157"><span class="linenos">157</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> +</span><span id="Teradata.Parser-158"><a href="#Teradata.Parser-158"><span class="linenos">158</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> +</span><span id="Teradata.Parser-159"><a href="#Teradata.Parser-159"><span class="linenos">159</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">joins</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Teradata.Parser-160"><a href="#Teradata.Parser-160"><span class="linenos">160</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">)</span> +</span><span id="Teradata.Parser-161"><a href="#Teradata.Parser-161"><span class="linenos">161</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> +</span><span id="Teradata.Parser-162"><a href="#Teradata.Parser-162"><span class="linenos">162</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> +</span><span id="Teradata.Parser-163"><a href="#Teradata.Parser-163"><span class="linenos">163</span></a> <span class="p">},</span> +</span><span id="Teradata.Parser-164"><a href="#Teradata.Parser-164"><span class="linenos">164</span></a> <span class="p">)</span> +</span><span id="Teradata.Parser-165"><a href="#Teradata.Parser-165"><span class="linenos">165</span></a> +</span><span id="Teradata.Parser-166"><a href="#Teradata.Parser-166"><span class="linenos">166</span></a> <span class="k">def</span> <span class="nf">_parse_rangen</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Teradata.Parser-167"><a href="#Teradata.Parser-167"><span class="linenos">167</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Teradata.Parser-168"><a href="#Teradata.Parser-168"><span class="linenos">168</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">)</span> +</span><span id="Teradata.Parser-169"><a href="#Teradata.Parser-169"><span class="linenos">169</span></a> +</span><span id="Teradata.Parser-170"><a href="#Teradata.Parser-170"><span class="linenos">170</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Teradata.Parser-171"><a href="#Teradata.Parser-171"><span class="linenos">171</span></a> <span class="n">each</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"EACH"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Teradata.Parser-172"><a href="#Teradata.Parser-172"><span class="linenos">172</span></a> +</span><span id="Teradata.Parser-173"><a href="#Teradata.Parser-173"><span class="linenos">173</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RangeN</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">each</span><span class="o">=</span><span class="n">each</span><span class="p">)</span> </span></pre></div> @@ -1368,11 +1374,23 @@ Default: 3</li> </div> + <div id="Teradata.Parser.VALUES_FOLLOWED_BY_PAREN" class="classattr"> + <div class="attr variable"> + <span class="name">VALUES_FOLLOWED_BY_PAREN</span> = +<span class="default_value">False</span> + + + </div> + <a class="headerlink" href="#Teradata.Parser.VALUES_FOLLOWED_BY_PAREN"></a> + + + + </div> <div id="Teradata.Parser.CHARSET_TRANSLATORS" class="classattr"> <div class="attr variable"> <span class="name">CHARSET_TRANSLATORS</span> = <input id="Teradata.Parser.CHARSET_TRANSLATORS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="Teradata.Parser.CHARSET_TRANSLATORS-view-value"></label><span class="default_value">{'KANJI1_SBC_TO_UNICODE', 'UNICODE_TO_LATIN', 'UNICODE_TO_UNICODE_NFC', 'KANJI1_KanjiEUC_TO_UNICODE', 'GRAPHIC_TO_KANJISJIS', 'UNICODE_TO_UNICODE_Fullwidth', 'UNICODE_TO_GRAPHIC_PadGraphic', 'UNICODE_TO_GRAPHIC', 'UNICODE_TO_KANJI1_KanjiEBCDIC', 'KANJI1_KANJISJIS_TO_UNICODE', 'UNICODE_TO_KANJI1_KANJISJIS', 'GRAPHIC_TO_UNICODE', 'GRAPHIC_TO_UNICODE_PadSpace', 'LATIN_TO_GRAPHIC', 'LATIN_TO_UNICODE', 'UNICODE_TO_KANJISJIS', 'UNICODE_TO_GRAPHIC_VarGraphic', 'KANJISJIS_TO_GRAPHIC', 'UNICODE_TO_UNICODE_FoldSpace', 'UNICODE_TO_KANJI1_SBC', 'UNICODE_TO_UNICODE_NFKC', 'KANJI1_KanjiEBCDIC_TO_UNICODE', 'LOCALE_TO_UNICODE', 'KANJISJIS_TO_UNICODE', 'KANJISJIS_TO_LATIN', 'GRAPHIC_TO_LATIN', 'UNICODE_TO_LOCALE', 'UNICODE_TO_UNICODE_NFKD', 'LATIN_TO_KANJISJIS', 'UNICODE_TO_KANJI1_KanjiEUC', 'UNICODE_TO_UNICODE_Halfwidth', 'UNICODE_TO_UNICODE_NFD'}</span> + <label class="view-value-button pdoc-button" for="Teradata.Parser.CHARSET_TRANSLATORS-view-value"></label><span class="default_value">{'GRAPHIC_TO_KANJISJIS', 'LOCALE_TO_UNICODE', 'KANJI1_KanjiEBCDIC_TO_UNICODE', 'GRAPHIC_TO_LATIN', 'UNICODE_TO_UNICODE_NFC', 'UNICODE_TO_UNICODE_Halfwidth', 'UNICODE_TO_UNICODE_NFKD', 'KANJISJIS_TO_UNICODE', 'LATIN_TO_UNICODE', 'LATIN_TO_GRAPHIC', 'KANJI1_SBC_TO_UNICODE', 'UNICODE_TO_LOCALE', 'GRAPHIC_TO_UNICODE_PadSpace', 'UNICODE_TO_GRAPHIC_VarGraphic', 'UNICODE_TO_UNICODE_Fullwidth', 'UNICODE_TO_GRAPHIC', 'UNICODE_TO_LATIN', 'GRAPHIC_TO_UNICODE', 'KANJISJIS_TO_LATIN', 'KANJI1_KanjiEUC_TO_UNICODE', 'UNICODE_TO_KANJI1_KANJISJIS', 'LATIN_TO_KANJISJIS', 'UNICODE_TO_UNICODE_NFKC', 'KANJI1_KANJISJIS_TO_UNICODE', 'UNICODE_TO_GRAPHIC_PadGraphic', 'UNICODE_TO_KANJI1_KanjiEUC', 'UNICODE_TO_UNICODE_FoldSpace', 'UNICODE_TO_UNICODE_NFD', 'KANJISJIS_TO_GRAPHIC', 'UNICODE_TO_KANJI1_SBC', 'UNICODE_TO_KANJI1_KanjiEBCDIC', 'UNICODE_TO_KANJISJIS'}</span> </div> @@ -1385,7 +1403,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">FUNC_TOKENS</span> = <input id="Teradata.Parser.FUNC_TOKENS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="Teradata.Parser.FUNC_TOKENS-view-value"></label><span class="default_value">{<TokenType.RLIKE: 'RLIKE'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.ILIKE: 'ILIKE'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, <TokenType.TEXT: 'TEXT'>, <TokenType.UINT: 'UINT'>, <TokenType.XOR: 'XOR'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.TABLE: 'TABLE'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.VAR: 'VAR'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.ANY: 'ANY'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.ALL: 'ALL'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.NESTED: 'NESTED'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.JSON: 'JSON'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.JSONB: 'JSONB'>, <TokenType.ROW: 'ROW'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.RANGE: 'RANGE'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.BIT: 'BIT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.INT256: 'INT256'>, <TokenType.CHAR: 'CHAR'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.NULL: 'NULL'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.LIKE: 'LIKE'>, <TokenType.FIRST: 'FIRST'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.YEAR: 'YEAR'>, <TokenType.UINT256: 'UINT256'>, <TokenType.UINT128: 'UINT128'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.LEFT: 'LEFT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.BINARY: 'BINARY'>, <TokenType.TIME: 'TIME'>, <TokenType.MONEY: 'MONEY'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.IPV6: 'IPV6'>, <TokenType.INT: 'INT'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.SOME: 'SOME'>, <TokenType.SUPER: 'SUPER'>, <TokenType.DATE: 'DATE'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.MAP: 'MAP'>, <TokenType.INSERT: 'INSERT'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.IPV4: 'IPV4'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UUID: 'UUID'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.GLOB: 'GLOB'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.INET: 'INET'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.DATE32: 'DATE32'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.INT128: 'INT128'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.MERGE: 'MERGE'>, <TokenType.XML: 'XML'>, <TokenType.STRUCT: 'STRUCT'>}</span> + <label class="view-value-button pdoc-button" for="Teradata.Parser.FUNC_TOKENS-view-value"></label><span class="default_value">{<TokenType.BIT: 'BIT'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.TIME: 'TIME'>, <TokenType.FIRST: 'FIRST'>, <TokenType.RANGE: 'RANGE'>, <TokenType.INT: 'INT'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.RLIKE: 'RLIKE'>, <TokenType.XML: 'XML'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.VAR: 'VAR'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.MERGE: 'MERGE'>, <TokenType.ANY: 'ANY'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.LEFT: 'LEFT'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.JSONB: 'JSONB'>, <TokenType.ENUM: 'ENUM'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.INDEX: 'INDEX'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.LIKE: 'LIKE'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.IPV6: 'IPV6'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.BINARY: 'BINARY'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.DATE: 'DATE'>, <TokenType.SUPER: 'SUPER'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TEXT: 'TEXT'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.XOR: 'XOR'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.MONEY: 'MONEY'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.NULL: 'NULL'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.ILIKE: 'ILIKE'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.ALL: 'ALL'>, <TokenType.ROW: 'ROW'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.TABLE: 'TABLE'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.YEAR: 'YEAR'>, <TokenType.IPV4: 'IPV4'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.INT256: 'INT256'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.INET: 'INET'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.MAP: 'MAP'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.UINT: 'UINT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.UINT256: 'UINT256'>, <TokenType.CHAR: 'CHAR'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UINT128: 'UINT128'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.INSERT: 'INSERT'>, <TokenType.GLOB: 'GLOB'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.UUID: 'UUID'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.JSON: 'JSON'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.INT128: 'INT128'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.SOME: 'SOME'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>}</span> </div> @@ -1436,7 +1454,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">TABLE_ALIAS_TOKENS</span> = <input id="Teradata.Parser.TABLE_ALIAS_TOKENS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="Teradata.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.UPDATE: 'UPDATE'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.TEXT: 'TEXT'>, <TokenType.UINT: 'UINT'>, <TokenType.DELETE: 'DELETE'>, <TokenType.TOP: 'TOP'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.NEXT: 'NEXT'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.TABLE: 'TABLE'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.VAR: 'VAR'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.ANY: 'ANY'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.END: 'END'>, <TokenType.ALL: 'ALL'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.NESTED: 'NESTED'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.JSON: 'JSON'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.ANTI: 'ANTI'>, <TokenType.JSONB: 'JSONB'>, <TokenType.ROW: 'ROW'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SEMI: 'SEMI'>, <TokenType.RANGE: 'RANGE'>, <TokenType.SET: 'SET'>, <TokenType.IS: 'IS'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.BIT: 'BIT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.INT256: 'INT256'>, <TokenType.FALSE: 'FALSE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.ASC: 'ASC'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.SHOW: 'SHOW'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.NULL: 'NULL'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.DIV: 'DIV'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.CASE: 'CASE'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.FIRST: 'FIRST'>, <TokenType.YEAR: 'YEAR'>, <TokenType.UINT256: 'UINT256'>, <TokenType.MODEL: 'MODEL'>, <TokenType.UINT128: 'UINT128'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.BINARY: 'BINARY'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.USE: 'USE'>, <TokenType.TIME: 'TIME'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.LOAD: 'LOAD'>, <TokenType.CACHE: 'CACHE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.IPV6: 'IPV6'>, <TokenType.INT: 'INT'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.SOME: 'SOME'>, <TokenType.SUPER: 'SUPER'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.KILL: 'KILL'>, <TokenType.DATE: 'DATE'>, <TokenType.DESC: 'DESC'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.MAP: 'MAP'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.IPV4: 'IPV4'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UUID: 'UUID'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.ROWS: 'ROWS'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.INET: 'INET'>, <TokenType.FINAL: 'FINAL'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.DATE32: 'DATE32'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.INT128: 'INT128'>, <TokenType.MERGE: 'MERGE'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.XML: 'XML'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.STRUCT: 'STRUCT'>}</span> + <label class="view-value-button pdoc-button" for="Teradata.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.BIT: 'BIT'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.FIRST: 'FIRST'>, <TokenType.RANGE: 'RANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.INT: 'INT'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.IS: 'IS'>, <TokenType.XML: 'XML'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.VAR: 'VAR'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.ROWS: 'ROWS'>, <TokenType.MERGE: 'MERGE'>, <TokenType.ANY: 'ANY'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.CACHE: 'CACHE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.INDEX: 'INDEX'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.FINAL: 'FINAL'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.USE: 'USE'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.IPV6: 'IPV6'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.ASC: 'ASC'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.BINARY: 'BINARY'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.DATE: 'DATE'>, <TokenType.SUPER: 'SUPER'>, <TokenType.TOP: 'TOP'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TEXT: 'TEXT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.SHOW: 'SHOW'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.SET: 'SET'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.MONEY: 'MONEY'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.NULL: 'NULL'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.NEXT: 'NEXT'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.ALL: 'ALL'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.ROW: 'ROW'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.TABLE: 'TABLE'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.CASE: 'CASE'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.MODEL: 'MODEL'>, <TokenType.YEAR: 'YEAR'>, <TokenType.IPV4: 'IPV4'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.INT256: 'INT256'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.INET: 'INET'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.MAP: 'MAP'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.UINT: 'UINT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.UINT256: 'UINT256'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.CHAR: 'CHAR'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.DIV: 'DIV'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UINT128: 'UINT128'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.DELETE: 'DELETE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.UUID: 'UUID'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.VIEW: 'VIEW'>, <TokenType.JSON: 'JSON'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.END: 'END'>, <TokenType.INT128: 'INT128'>, <TokenType.KILL: 'KILL'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.SEMI: 'SEMI'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.SOME: 'SOME'>, <TokenType.ANTI: 'ANTI'>, <TokenType.FALSE: 'FALSE'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.DESC: 'DESC'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.UPDATE: 'UPDATE'>}</span> </div> @@ -1582,102 +1600,102 @@ Default: 3</li> </div> <a class="headerlink" href="#Teradata.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator-174"><a href="#Teradata.Generator-174"><span class="linenos">174</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="Teradata.Generator-175"><a href="#Teradata.Generator-175"><span class="linenos">175</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata.Generator-176"><a href="#Teradata.Generator-176"><span class="linenos">176</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata.Generator-177"><a href="#Teradata.Generator-177"><span class="linenos">177</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata.Generator-178"><a href="#Teradata.Generator-178"><span class="linenos">178</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata.Generator-179"><a href="#Teradata.Generator-179"><span class="linenos">179</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> -</span><span id="Teradata.Generator-180"><a href="#Teradata.Generator-180"><span class="linenos">180</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata.Generator-181"><a href="#Teradata.Generator-181"><span class="linenos">181</span></a> -</span><span id="Teradata.Generator-182"><a href="#Teradata.Generator-182"><span class="linenos">182</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Generator-183"><a href="#Teradata.Generator-183"><span class="linenos">183</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="Teradata.Generator-184"><a href="#Teradata.Generator-184"><span class="linenos">184</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">GEOMETRY</span><span class="p">:</span> <span class="s2">"ST_GEOMETRY"</span><span class="p">,</span> -</span><span id="Teradata.Generator-185"><a href="#Teradata.Generator-185"><span class="linenos">185</span></a> <span class="p">}</span> -</span><span id="Teradata.Generator-186"><a href="#Teradata.Generator-186"><span class="linenos">186</span></a> -</span><span id="Teradata.Generator-187"><a href="#Teradata.Generator-187"><span class="linenos">187</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Generator-188"><a href="#Teradata.Generator-188"><span class="linenos">188</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Teradata.Generator-189"><a href="#Teradata.Generator-189"><span class="linenos">189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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_INDEX</span><span class="p">,</span> -</span><span id="Teradata.Generator-190"><a href="#Teradata.Generator-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="Teradata.Generator-191"><a href="#Teradata.Generator-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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_CREATE</span><span class="p">,</span> -</span><span id="Teradata.Generator-192"><a href="#Teradata.Generator-192"><span class="linenos">192</span></a> <span class="p">}</span> -</span><span id="Teradata.Generator-193"><a href="#Teradata.Generator-193"><span class="linenos">193</span></a> -</span><span id="Teradata.Generator-194"><a href="#Teradata.Generator-194"><span class="linenos">194</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Generator-195"><a href="#Teradata.Generator-195"><span class="linenos">195</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="Teradata.Generator-196"><a href="#Teradata.Generator-196"><span class="linenos">196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> -</span><span id="Teradata.Generator-197"><a href="#Teradata.Generator-197"><span class="linenos">197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> -</span><span id="Teradata.Generator-198"><a href="#Teradata.Generator-198"><span class="linenos">198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="Teradata.Generator-199"><a href="#Teradata.Generator-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="Teradata.Generator-200"><a href="#Teradata.Generator-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pow</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">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"**"</span><span class="p">),</span> -</span><span id="Teradata.Generator-201"><a href="#Teradata.Generator-201"><span class="linenos">201</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Teradata.Generator-202"><a href="#Teradata.Generator-202"><span class="linenos">202</span></a> <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 class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">]</span> -</span><span id="Teradata.Generator-203"><a href="#Teradata.Generator-203"><span class="linenos">203</span></a> <span class="p">),</span> -</span><span id="Teradata.Generator-204"><a href="#Teradata.Generator-204"><span class="linenos">204</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="Teradata.Generator-205"><a href="#Teradata.Generator-205"><span class="linenos">205</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Teradata.Generator-206"><a href="#Teradata.Generator-206"><span class="linenos">206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Teradata.Generator-207"><a href="#Teradata.Generator-207"><span class="linenos">207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</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">"DATABASE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Teradata.Generator-208"><a href="#Teradata.Generator-208"><span class="linenos">208</span></a> <span class="p">}</span> -</span><span id="Teradata.Generator-209"><a href="#Teradata.Generator-209"><span class="linenos">209</span></a> -</span><span id="Teradata.Generator-210"><a href="#Teradata.Generator-210"><span class="linenos">210</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-211"><a href="#Teradata.Generator-211"><span class="linenos">211</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span> <span class="ow">and</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">"format"</span><span class="p">):</span> -</span><span id="Teradata.Generator-212"><a href="#Teradata.Generator-212"><span class="linenos">212</span></a> <span class="c1"># We don't actually want to print the unknown type in CAST(<value> AS FORMAT <format>)</span> -</span><span id="Teradata.Generator-213"><a href="#Teradata.Generator-213"><span class="linenos">213</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> -</span><span id="Teradata.Generator-214"><a href="#Teradata.Generator-214"><span class="linenos">214</span></a> -</span><span id="Teradata.Generator-215"><a href="#Teradata.Generator-215"><span class="linenos">215</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> -</span><span id="Teradata.Generator-216"><a href="#Teradata.Generator-216"><span class="linenos">216</span></a> -</span><span id="Teradata.Generator-217"><a href="#Teradata.Generator-217"><span class="linenos">217</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-218"><a href="#Teradata.Generator-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY"</span><span class="p">)</span> -</span><span id="Teradata.Generator-219"><a href="#Teradata.Generator-219"><span class="linenos">219</span></a> -</span><span id="Teradata.Generator-220"><a href="#Teradata.Generator-220"><span class="linenos">220</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Teradata.Generator-221"><a href="#Teradata.Generator-221"><span class="linenos">221</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Teradata.Generator-222"><a href="#Teradata.Generator-222"><span class="linenos">222</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> -</span><span id="Teradata.Generator-223"><a href="#Teradata.Generator-223"><span class="linenos">223</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> -</span><span id="Teradata.Generator-224"><a href="#Teradata.Generator-224"><span class="linenos">224</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Teradata.Generator-225"><a href="#Teradata.Generator-225"><span class="linenos">225</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-226"><a href="#Teradata.Generator-226"><span class="linenos">226</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> SAMPLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata.Generator-227"><a href="#Teradata.Generator-227"><span class="linenos">227</span></a> -</span><span id="Teradata.Generator-228"><a href="#Teradata.Generator-228"><span class="linenos">228</span></a> <span class="k">def</span> <span class="nf">partitionedbyproperty_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">PartitionedByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-229"><a href="#Teradata.Generator-229"><span class="linenos">229</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata.Generator-230"><a href="#Teradata.Generator-230"><span class="linenos">230</span></a> -</span><span id="Teradata.Generator-231"><a href="#Teradata.Generator-231"><span class="linenos">231</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="Teradata.Generator-232"><a href="#Teradata.Generator-232"><span class="linenos">232</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> -</span><span id="Teradata.Generator-233"><a href="#Teradata.Generator-233"><span class="linenos">233</span></a> <span class="k">def</span> <span class="nf">update_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">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-234"><a href="#Teradata.Generator-234"><span class="linenos">234</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Teradata.Generator-235"><a href="#Teradata.Generator-235"><span class="linenos">235</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> -</span><span id="Teradata.Generator-236"><a href="#Teradata.Generator-236"><span class="linenos">236</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Teradata.Generator-237"><a href="#Teradata.Generator-237"><span class="linenos">237</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Teradata.Generator-238"><a href="#Teradata.Generator-238"><span class="linenos">238</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata.Generator-239"><a href="#Teradata.Generator-239"><span class="linenos">239</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Teradata.Generator-240"><a href="#Teradata.Generator-240"><span class="linenos">240</span></a> -</span><span id="Teradata.Generator-241"><a href="#Teradata.Generator-241"><span class="linenos">241</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-242"><a href="#Teradata.Generator-242"><span class="linenos">242</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"MOD"</span><span class="p">)</span> -</span><span id="Teradata.Generator-243"><a href="#Teradata.Generator-243"><span class="linenos">243</span></a> -</span><span id="Teradata.Generator-244"><a href="#Teradata.Generator-244"><span class="linenos">244</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-245"><a href="#Teradata.Generator-245"><span class="linenos">245</span></a> <span class="n">type_sql</span> <span class="o">=</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="Teradata.Generator-246"><a href="#Teradata.Generator-246"><span class="linenos">246</span></a> <span class="n">prefix_sql</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">"prefix"</span><span class="p">)</span> -</span><span id="Teradata.Generator-247"><a href="#Teradata.Generator-247"><span class="linenos">247</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SYSUDTLIB.</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">prefix_sql</span> <span class="k">else</span> <span class="n">type_sql</span> -</span><span id="Teradata.Generator-248"><a href="#Teradata.Generator-248"><span class="linenos">248</span></a> -</span><span id="Teradata.Generator-249"><a href="#Teradata.Generator-249"><span class="linenos">249</span></a> <span class="k">def</span> <span class="nf">rangen_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">RangeN</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-250"><a href="#Teradata.Generator-250"><span class="linenos">250</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Teradata.Generator-251"><a href="#Teradata.Generator-251"><span class="linenos">251</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Teradata.Generator-252"><a href="#Teradata.Generator-252"><span class="linenos">252</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">)</span> -</span><span id="Teradata.Generator-253"><a href="#Teradata.Generator-253"><span class="linenos">253</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" EACH </span><span class="si">{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">each_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Teradata.Generator-254"><a href="#Teradata.Generator-254"><span class="linenos">254</span></a> -</span><span id="Teradata.Generator-255"><a href="#Teradata.Generator-255"><span class="linenos">255</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RANGE_N(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Teradata.Generator-256"><a href="#Teradata.Generator-256"><span class="linenos">256</span></a> -</span><span id="Teradata.Generator-257"><a href="#Teradata.Generator-257"><span class="linenos">257</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-258"><a href="#Teradata.Generator-258"><span class="linenos">258</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Teradata.Generator-259"><a href="#Teradata.Generator-259"><span class="linenos">259</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"TABLE"</span> <span class="ow">and</span> <span class="n">locations</span><span class="o">.</span><span class="n">get</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_NAME</span><span class="p">):</span> -</span><span id="Teradata.Generator-260"><a href="#Teradata.Generator-260"><span class="linenos">260</span></a> <span class="n">this_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Teradata.Generator-261"><a href="#Teradata.Generator-261"><span class="linenos">261</span></a> <span class="n">this_properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Teradata.Generator-262"><a href="#Teradata.Generator-262"><span class="linenos">262</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">locations</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_NAME</span><span class="p">]),</span> -</span><span id="Teradata.Generator-263"><a href="#Teradata.Generator-263"><span class="linenos">263</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Teradata.Generator-264"><a href="#Teradata.Generator-264"><span class="linenos">264</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> -</span><span id="Teradata.Generator-265"><a href="#Teradata.Generator-265"><span class="linenos">265</span></a> <span class="p">)</span> -</span><span id="Teradata.Generator-266"><a href="#Teradata.Generator-266"><span class="linenos">266</span></a> <span class="n">this_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Teradata.Generator-267"><a href="#Teradata.Generator-267"><span class="linenos">267</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this_name</span><span class="si">}{</span><span class="n">this_properties</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this_schema</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata.Generator-268"><a href="#Teradata.Generator-268"><span class="linenos">268</span></a> -</span><span id="Teradata.Generator-269"><a href="#Teradata.Generator-269"><span class="linenos">269</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">locations</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator-175"><a href="#Teradata.Generator-175"><span class="linenos">175</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="Teradata.Generator-176"><a href="#Teradata.Generator-176"><span class="linenos">176</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Teradata.Generator-177"><a href="#Teradata.Generator-177"><span class="linenos">177</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata.Generator-178"><a href="#Teradata.Generator-178"><span class="linenos">178</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata.Generator-179"><a href="#Teradata.Generator-179"><span class="linenos">179</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata.Generator-180"><a href="#Teradata.Generator-180"><span class="linenos">180</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> +</span><span id="Teradata.Generator-181"><a href="#Teradata.Generator-181"><span class="linenos">181</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata.Generator-182"><a href="#Teradata.Generator-182"><span class="linenos">182</span></a> +</span><span id="Teradata.Generator-183"><a href="#Teradata.Generator-183"><span class="linenos">183</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Generator-184"><a href="#Teradata.Generator-184"><span class="linenos">184</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="Teradata.Generator-185"><a href="#Teradata.Generator-185"><span class="linenos">185</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">GEOMETRY</span><span class="p">:</span> <span class="s2">"ST_GEOMETRY"</span><span class="p">,</span> +</span><span id="Teradata.Generator-186"><a href="#Teradata.Generator-186"><span class="linenos">186</span></a> <span class="p">}</span> +</span><span id="Teradata.Generator-187"><a href="#Teradata.Generator-187"><span class="linenos">187</span></a> +</span><span id="Teradata.Generator-188"><a href="#Teradata.Generator-188"><span class="linenos">188</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Generator-189"><a href="#Teradata.Generator-189"><span class="linenos">189</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Teradata.Generator-190"><a href="#Teradata.Generator-190"><span class="linenos">190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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_INDEX</span><span class="p">,</span> +</span><span id="Teradata.Generator-191"><a href="#Teradata.Generator-191"><span class="linenos">191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="Teradata.Generator-192"><a href="#Teradata.Generator-192"><span class="linenos">192</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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_CREATE</span><span class="p">,</span> +</span><span id="Teradata.Generator-193"><a href="#Teradata.Generator-193"><span class="linenos">193</span></a> <span class="p">}</span> +</span><span id="Teradata.Generator-194"><a href="#Teradata.Generator-194"><span class="linenos">194</span></a> +</span><span id="Teradata.Generator-195"><a href="#Teradata.Generator-195"><span class="linenos">195</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Generator-196"><a href="#Teradata.Generator-196"><span class="linenos">196</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="Teradata.Generator-197"><a href="#Teradata.Generator-197"><span class="linenos">197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAX_BY"</span><span class="p">),</span> +</span><span id="Teradata.Generator-198"><a href="#Teradata.Generator-198"><span class="linenos">198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN_BY"</span><span class="p">),</span> +</span><span id="Teradata.Generator-199"><a href="#Teradata.Generator-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="Teradata.Generator-200"><a href="#Teradata.Generator-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="Teradata.Generator-201"><a href="#Teradata.Generator-201"><span class="linenos">201</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pow</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">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"**"</span><span class="p">),</span> +</span><span id="Teradata.Generator-202"><a href="#Teradata.Generator-202"><span class="linenos">202</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Teradata.Generator-203"><a href="#Teradata.Generator-203"><span class="linenos">203</span></a> <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 class="n">transforms</span><span class="o">.</span><span class="n">eliminate_semi_and_anti_joins</span><span class="p">]</span> +</span><span id="Teradata.Generator-204"><a href="#Teradata.Generator-204"><span class="linenos">204</span></a> <span class="p">),</span> +</span><span id="Teradata.Generator-205"><a href="#Teradata.Generator-205"><span class="linenos">205</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="Teradata.Generator-206"><a href="#Teradata.Generator-206"><span class="linenos">206</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Teradata.Generator-207"><a href="#Teradata.Generator-207"><span class="linenos">207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Teradata.Generator-208"><a href="#Teradata.Generator-208"><span class="linenos">208</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Use</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">"DATABASE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Teradata.Generator-209"><a href="#Teradata.Generator-209"><span class="linenos">209</span></a> <span class="p">}</span> +</span><span id="Teradata.Generator-210"><a href="#Teradata.Generator-210"><span class="linenos">210</span></a> +</span><span id="Teradata.Generator-211"><a href="#Teradata.Generator-211"><span class="linenos">211</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-212"><a href="#Teradata.Generator-212"><span class="linenos">212</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span> <span class="ow">and</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">"format"</span><span class="p">):</span> +</span><span id="Teradata.Generator-213"><a href="#Teradata.Generator-213"><span class="linenos">213</span></a> <span class="c1"># We don't actually want to print the unknown type in CAST(<value> AS FORMAT <format>)</span> +</span><span id="Teradata.Generator-214"><a href="#Teradata.Generator-214"><span class="linenos">214</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> +</span><span id="Teradata.Generator-215"><a href="#Teradata.Generator-215"><span class="linenos">215</span></a> +</span><span id="Teradata.Generator-216"><a href="#Teradata.Generator-216"><span class="linenos">216</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> +</span><span id="Teradata.Generator-217"><a href="#Teradata.Generator-217"><span class="linenos">217</span></a> +</span><span id="Teradata.Generator-218"><a href="#Teradata.Generator-218"><span class="linenos">218</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-219"><a href="#Teradata.Generator-219"><span class="linenos">219</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY"</span><span class="p">)</span> +</span><span id="Teradata.Generator-220"><a href="#Teradata.Generator-220"><span class="linenos">220</span></a> +</span><span id="Teradata.Generator-221"><a href="#Teradata.Generator-221"><span class="linenos">221</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="Teradata.Generator-222"><a href="#Teradata.Generator-222"><span class="linenos">222</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Teradata.Generator-223"><a href="#Teradata.Generator-223"><span class="linenos">223</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> +</span><span id="Teradata.Generator-224"><a href="#Teradata.Generator-224"><span class="linenos">224</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> +</span><span id="Teradata.Generator-225"><a href="#Teradata.Generator-225"><span class="linenos">225</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Teradata.Generator-226"><a href="#Teradata.Generator-226"><span class="linenos">226</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-227"><a href="#Teradata.Generator-227"><span class="linenos">227</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> SAMPLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata.Generator-228"><a href="#Teradata.Generator-228"><span class="linenos">228</span></a> +</span><span id="Teradata.Generator-229"><a href="#Teradata.Generator-229"><span class="linenos">229</span></a> <span class="k">def</span> <span class="nf">partitionedbyproperty_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">PartitionedByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-230"><a href="#Teradata.Generator-230"><span class="linenos">230</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata.Generator-231"><a href="#Teradata.Generator-231"><span class="linenos">231</span></a> +</span><span id="Teradata.Generator-232"><a href="#Teradata.Generator-232"><span class="linenos">232</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="Teradata.Generator-233"><a href="#Teradata.Generator-233"><span class="linenos">233</span></a> <span class="c1"># https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/Teradata-VantageTM-SQL-Data-Manipulation-Language-17.20/Statement-Syntax/UPDATE/UPDATE-Syntax-Basic-Form-FROM-Clause</span> +</span><span id="Teradata.Generator-234"><a href="#Teradata.Generator-234"><span class="linenos">234</span></a> <span class="k">def</span> <span class="nf">update_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">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-235"><a href="#Teradata.Generator-235"><span class="linenos">235</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Teradata.Generator-236"><a href="#Teradata.Generator-236"><span class="linenos">236</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> +</span><span id="Teradata.Generator-237"><a href="#Teradata.Generator-237"><span class="linenos">237</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Teradata.Generator-238"><a href="#Teradata.Generator-238"><span class="linenos">238</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Teradata.Generator-239"><a href="#Teradata.Generator-239"><span class="linenos">239</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata.Generator-240"><a href="#Teradata.Generator-240"><span class="linenos">240</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Teradata.Generator-241"><a href="#Teradata.Generator-241"><span class="linenos">241</span></a> +</span><span id="Teradata.Generator-242"><a href="#Teradata.Generator-242"><span class="linenos">242</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-243"><a href="#Teradata.Generator-243"><span class="linenos">243</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"MOD"</span><span class="p">)</span> +</span><span id="Teradata.Generator-244"><a href="#Teradata.Generator-244"><span class="linenos">244</span></a> +</span><span id="Teradata.Generator-245"><a href="#Teradata.Generator-245"><span class="linenos">245</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-246"><a href="#Teradata.Generator-246"><span class="linenos">246</span></a> <span class="n">type_sql</span> <span class="o">=</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="Teradata.Generator-247"><a href="#Teradata.Generator-247"><span class="linenos">247</span></a> <span class="n">prefix_sql</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">"prefix"</span><span class="p">)</span> +</span><span id="Teradata.Generator-248"><a href="#Teradata.Generator-248"><span class="linenos">248</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SYSUDTLIB.</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">prefix_sql</span> <span class="k">else</span> <span class="n">type_sql</span> +</span><span id="Teradata.Generator-249"><a href="#Teradata.Generator-249"><span class="linenos">249</span></a> +</span><span id="Teradata.Generator-250"><a href="#Teradata.Generator-250"><span class="linenos">250</span></a> <span class="k">def</span> <span class="nf">rangen_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">RangeN</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-251"><a href="#Teradata.Generator-251"><span class="linenos">251</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Teradata.Generator-252"><a href="#Teradata.Generator-252"><span class="linenos">252</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Teradata.Generator-253"><a href="#Teradata.Generator-253"><span class="linenos">253</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">)</span> +</span><span id="Teradata.Generator-254"><a href="#Teradata.Generator-254"><span class="linenos">254</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" EACH </span><span class="si">{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">each_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Teradata.Generator-255"><a href="#Teradata.Generator-255"><span class="linenos">255</span></a> +</span><span id="Teradata.Generator-256"><a href="#Teradata.Generator-256"><span class="linenos">256</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RANGE_N(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Teradata.Generator-257"><a href="#Teradata.Generator-257"><span class="linenos">257</span></a> +</span><span id="Teradata.Generator-258"><a href="#Teradata.Generator-258"><span class="linenos">258</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-259"><a href="#Teradata.Generator-259"><span class="linenos">259</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Teradata.Generator-260"><a href="#Teradata.Generator-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"TABLE"</span> <span class="ow">and</span> <span class="n">locations</span><span class="o">.</span><span class="n">get</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_NAME</span><span class="p">):</span> +</span><span id="Teradata.Generator-261"><a href="#Teradata.Generator-261"><span class="linenos">261</span></a> <span class="n">this_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Teradata.Generator-262"><a href="#Teradata.Generator-262"><span class="linenos">262</span></a> <span class="n">this_properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Teradata.Generator-263"><a href="#Teradata.Generator-263"><span class="linenos">263</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">locations</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_NAME</span><span class="p">]),</span> +</span><span id="Teradata.Generator-264"><a href="#Teradata.Generator-264"><span class="linenos">264</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Teradata.Generator-265"><a href="#Teradata.Generator-265"><span class="linenos">265</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> +</span><span id="Teradata.Generator-266"><a href="#Teradata.Generator-266"><span class="linenos">266</span></a> <span class="p">)</span> +</span><span id="Teradata.Generator-267"><a href="#Teradata.Generator-267"><span class="linenos">267</span></a> <span class="n">this_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Teradata.Generator-268"><a href="#Teradata.Generator-268"><span class="linenos">268</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this_name</span><span class="si">}{</span><span class="n">this_properties</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this_schema</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata.Generator-269"><a href="#Teradata.Generator-269"><span class="linenos">269</span></a> +</span><span id="Teradata.Generator-270"><a href="#Teradata.Generator-270"><span class="linenos">270</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">locations</span><span class="p">)</span> </span></pre></div> @@ -1842,12 +1860,12 @@ Default: True</li> </div> <a class="headerlink" href="#Teradata.Generator.cast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.cast_sql-210"><a href="#Teradata.Generator.cast_sql-210"><span class="linenos">210</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator.cast_sql-211"><a href="#Teradata.Generator.cast_sql-211"><span class="linenos">211</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span> <span class="ow">and</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">"format"</span><span class="p">):</span> -</span><span id="Teradata.Generator.cast_sql-212"><a href="#Teradata.Generator.cast_sql-212"><span class="linenos">212</span></a> <span class="c1"># We don't actually want to print the unknown type in CAST(<value> AS FORMAT <format>)</span> -</span><span id="Teradata.Generator.cast_sql-213"><a href="#Teradata.Generator.cast_sql-213"><span class="linenos">213</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> -</span><span id="Teradata.Generator.cast_sql-214"><a href="#Teradata.Generator.cast_sql-214"><span class="linenos">214</span></a> -</span><span id="Teradata.Generator.cast_sql-215"><a href="#Teradata.Generator.cast_sql-215"><span class="linenos">215</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.cast_sql-211"><a href="#Teradata.Generator.cast_sql-211"><span class="linenos">211</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.cast_sql-212"><a href="#Teradata.Generator.cast_sql-212"><span class="linenos">212</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span> <span class="ow">and</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">"format"</span><span class="p">):</span> +</span><span id="Teradata.Generator.cast_sql-213"><a href="#Teradata.Generator.cast_sql-213"><span class="linenos">213</span></a> <span class="c1"># We don't actually want to print the unknown type in CAST(<value> AS FORMAT <format>)</span> +</span><span id="Teradata.Generator.cast_sql-214"><a href="#Teradata.Generator.cast_sql-214"><span class="linenos">214</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> +</span><span id="Teradata.Generator.cast_sql-215"><a href="#Teradata.Generator.cast_sql-215"><span class="linenos">215</span></a> +</span><span id="Teradata.Generator.cast_sql-216"><a href="#Teradata.Generator.cast_sql-216"><span class="linenos">216</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="n">safe_prefix</span><span class="p">)</span> </span></pre></div> @@ -1865,8 +1883,8 @@ Default: True</li> </div> <a class="headerlink" href="#Teradata.Generator.trycast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.trycast_sql-217"><a href="#Teradata.Generator.trycast_sql-217"><span class="linenos">217</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator.trycast_sql-218"><a href="#Teradata.Generator.trycast_sql-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.trycast_sql-218"><a href="#Teradata.Generator.trycast_sql-218"><span class="linenos">218</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.trycast_sql-219"><a href="#Teradata.Generator.trycast_sql-219"><span class="linenos">219</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY"</span><span class="p">)</span> </span></pre></div> @@ -1884,13 +1902,13 @@ Default: True</li> </div> <a class="headerlink" href="#Teradata.Generator.tablesample_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.tablesample_sql-220"><a href="#Teradata.Generator.tablesample_sql-220"><span class="linenos">220</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Teradata.Generator.tablesample_sql-221"><a href="#Teradata.Generator.tablesample_sql-221"><span class="linenos">221</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Teradata.Generator.tablesample_sql-222"><a href="#Teradata.Generator.tablesample_sql-222"><span class="linenos">222</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> -</span><span id="Teradata.Generator.tablesample_sql-223"><a href="#Teradata.Generator.tablesample_sql-223"><span class="linenos">223</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> -</span><span id="Teradata.Generator.tablesample_sql-224"><a href="#Teradata.Generator.tablesample_sql-224"><span class="linenos">224</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Teradata.Generator.tablesample_sql-225"><a href="#Teradata.Generator.tablesample_sql-225"><span class="linenos">225</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator.tablesample_sql-226"><a href="#Teradata.Generator.tablesample_sql-226"><span class="linenos">226</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> SAMPLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.tablesample_sql-221"><a href="#Teradata.Generator.tablesample_sql-221"><span class="linenos">221</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="Teradata.Generator.tablesample_sql-222"><a href="#Teradata.Generator.tablesample_sql-222"><span class="linenos">222</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Teradata.Generator.tablesample_sql-223"><a href="#Teradata.Generator.tablesample_sql-223"><span class="linenos">223</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> +</span><span id="Teradata.Generator.tablesample_sql-224"><a href="#Teradata.Generator.tablesample_sql-224"><span class="linenos">224</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> +</span><span id="Teradata.Generator.tablesample_sql-225"><a href="#Teradata.Generator.tablesample_sql-225"><span class="linenos">225</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Teradata.Generator.tablesample_sql-226"><a href="#Teradata.Generator.tablesample_sql-226"><span class="linenos">226</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.tablesample_sql-227"><a href="#Teradata.Generator.tablesample_sql-227"><span class="linenos">227</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> SAMPLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1908,8 +1926,8 @@ Default: True</li> </div> <a class="headerlink" href="#Teradata.Generator.partitionedbyproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.partitionedbyproperty_sql-228"><a href="#Teradata.Generator.partitionedbyproperty_sql-228"><span class="linenos">228</span></a> <span class="k">def</span> <span class="nf">partitionedbyproperty_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">PartitionedByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator.partitionedbyproperty_sql-229"><a href="#Teradata.Generator.partitionedbyproperty_sql-229"><span class="linenos">229</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.partitionedbyproperty_sql-229"><a href="#Teradata.Generator.partitionedbyproperty_sql-229"><span class="linenos">229</span></a> <span class="k">def</span> <span class="nf">partitionedbyproperty_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">PartitionedByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.partitionedbyproperty_sql-230"><a href="#Teradata.Generator.partitionedbyproperty_sql-230"><span class="linenos">230</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1927,13 +1945,13 @@ Default: True</li> </div> <a class="headerlink" href="#Teradata.Generator.update_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.update_sql-233"><a href="#Teradata.Generator.update_sql-233"><span class="linenos">233</span></a> <span class="k">def</span> <span class="nf">update_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">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator.update_sql-234"><a href="#Teradata.Generator.update_sql-234"><span class="linenos">234</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Teradata.Generator.update_sql-235"><a href="#Teradata.Generator.update_sql-235"><span class="linenos">235</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> -</span><span id="Teradata.Generator.update_sql-236"><a href="#Teradata.Generator.update_sql-236"><span class="linenos">236</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Teradata.Generator.update_sql-237"><a href="#Teradata.Generator.update_sql-237"><span class="linenos">237</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Teradata.Generator.update_sql-238"><a href="#Teradata.Generator.update_sql-238"><span class="linenos">238</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata.Generator.update_sql-239"><a href="#Teradata.Generator.update_sql-239"><span class="linenos">239</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.update_sql-234"><a href="#Teradata.Generator.update_sql-234"><span class="linenos">234</span></a> <span class="k">def</span> <span class="nf">update_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">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.update_sql-235"><a href="#Teradata.Generator.update_sql-235"><span class="linenos">235</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Teradata.Generator.update_sql-236"><a href="#Teradata.Generator.update_sql-236"><span class="linenos">236</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> +</span><span id="Teradata.Generator.update_sql-237"><a href="#Teradata.Generator.update_sql-237"><span class="linenos">237</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Teradata.Generator.update_sql-238"><a href="#Teradata.Generator.update_sql-238"><span class="linenos">238</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Teradata.Generator.update_sql-239"><a href="#Teradata.Generator.update_sql-239"><span class="linenos">239</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata.Generator.update_sql-240"><a href="#Teradata.Generator.update_sql-240"><span class="linenos">240</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -1951,8 +1969,8 @@ Default: True</li> </div> <a class="headerlink" href="#Teradata.Generator.mod_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.mod_sql-241"><a href="#Teradata.Generator.mod_sql-241"><span class="linenos">241</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator.mod_sql-242"><a href="#Teradata.Generator.mod_sql-242"><span class="linenos">242</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"MOD"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.mod_sql-242"><a href="#Teradata.Generator.mod_sql-242"><span class="linenos">242</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.mod_sql-243"><a href="#Teradata.Generator.mod_sql-243"><span class="linenos">243</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"MOD"</span><span class="p">)</span> </span></pre></div> @@ -1970,10 +1988,10 @@ Default: True</li> </div> <a class="headerlink" href="#Teradata.Generator.datatype_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.datatype_sql-244"><a href="#Teradata.Generator.datatype_sql-244"><span class="linenos">244</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator.datatype_sql-245"><a href="#Teradata.Generator.datatype_sql-245"><span class="linenos">245</span></a> <span class="n">type_sql</span> <span class="o">=</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="Teradata.Generator.datatype_sql-246"><a href="#Teradata.Generator.datatype_sql-246"><span class="linenos">246</span></a> <span class="n">prefix_sql</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">"prefix"</span><span class="p">)</span> -</span><span id="Teradata.Generator.datatype_sql-247"><a href="#Teradata.Generator.datatype_sql-247"><span class="linenos">247</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SYSUDTLIB.</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">prefix_sql</span> <span class="k">else</span> <span class="n">type_sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.datatype_sql-245"><a href="#Teradata.Generator.datatype_sql-245"><span class="linenos">245</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.datatype_sql-246"><a href="#Teradata.Generator.datatype_sql-246"><span class="linenos">246</span></a> <span class="n">type_sql</span> <span class="o">=</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="Teradata.Generator.datatype_sql-247"><a href="#Teradata.Generator.datatype_sql-247"><span class="linenos">247</span></a> <span class="n">prefix_sql</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">"prefix"</span><span class="p">)</span> +</span><span id="Teradata.Generator.datatype_sql-248"><a href="#Teradata.Generator.datatype_sql-248"><span class="linenos">248</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SYSUDTLIB.</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">prefix_sql</span> <span class="k">else</span> <span class="n">type_sql</span> </span></pre></div> @@ -1991,13 +2009,13 @@ Default: True</li> </div> <a class="headerlink" href="#Teradata.Generator.rangen_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.rangen_sql-249"><a href="#Teradata.Generator.rangen_sql-249"><span class="linenos">249</span></a> <span class="k">def</span> <span class="nf">rangen_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">RangeN</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator.rangen_sql-250"><a href="#Teradata.Generator.rangen_sql-250"><span class="linenos">250</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Teradata.Generator.rangen_sql-251"><a href="#Teradata.Generator.rangen_sql-251"><span class="linenos">251</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Teradata.Generator.rangen_sql-252"><a href="#Teradata.Generator.rangen_sql-252"><span class="linenos">252</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">)</span> -</span><span id="Teradata.Generator.rangen_sql-253"><a href="#Teradata.Generator.rangen_sql-253"><span class="linenos">253</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" EACH </span><span class="si">{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">each_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Teradata.Generator.rangen_sql-254"><a href="#Teradata.Generator.rangen_sql-254"><span class="linenos">254</span></a> -</span><span id="Teradata.Generator.rangen_sql-255"><a href="#Teradata.Generator.rangen_sql-255"><span class="linenos">255</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RANGE_N(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.rangen_sql-250"><a href="#Teradata.Generator.rangen_sql-250"><span class="linenos">250</span></a> <span class="k">def</span> <span class="nf">rangen_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">RangeN</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.rangen_sql-251"><a href="#Teradata.Generator.rangen_sql-251"><span class="linenos">251</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Teradata.Generator.rangen_sql-252"><a href="#Teradata.Generator.rangen_sql-252"><span class="linenos">252</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Teradata.Generator.rangen_sql-253"><a href="#Teradata.Generator.rangen_sql-253"><span class="linenos">253</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">)</span> +</span><span id="Teradata.Generator.rangen_sql-254"><a href="#Teradata.Generator.rangen_sql-254"><span class="linenos">254</span></a> <span class="n">each_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" EACH </span><span class="si">{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">each_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Teradata.Generator.rangen_sql-255"><a href="#Teradata.Generator.rangen_sql-255"><span class="linenos">255</span></a> +</span><span id="Teradata.Generator.rangen_sql-256"><a href="#Teradata.Generator.rangen_sql-256"><span class="linenos">256</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RANGE_N(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}{</span><span class="n">each_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -2015,19 +2033,19 @@ Default: True</li> </div> <a class="headerlink" href="#Teradata.Generator.createable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.createable_sql-257"><a href="#Teradata.Generator.createable_sql-257"><span class="linenos">257</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator.createable_sql-258"><a href="#Teradata.Generator.createable_sql-258"><span class="linenos">258</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Teradata.Generator.createable_sql-259"><a href="#Teradata.Generator.createable_sql-259"><span class="linenos">259</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"TABLE"</span> <span class="ow">and</span> <span class="n">locations</span><span class="o">.</span><span class="n">get</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_NAME</span><span class="p">):</span> -</span><span id="Teradata.Generator.createable_sql-260"><a href="#Teradata.Generator.createable_sql-260"><span class="linenos">260</span></a> <span class="n">this_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Teradata.Generator.createable_sql-261"><a href="#Teradata.Generator.createable_sql-261"><span class="linenos">261</span></a> <span class="n">this_properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Teradata.Generator.createable_sql-262"><a href="#Teradata.Generator.createable_sql-262"><span class="linenos">262</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">locations</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_NAME</span><span class="p">]),</span> -</span><span id="Teradata.Generator.createable_sql-263"><a href="#Teradata.Generator.createable_sql-263"><span class="linenos">263</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Teradata.Generator.createable_sql-264"><a href="#Teradata.Generator.createable_sql-264"><span class="linenos">264</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> -</span><span id="Teradata.Generator.createable_sql-265"><a href="#Teradata.Generator.createable_sql-265"><span class="linenos">265</span></a> <span class="p">)</span> -</span><span id="Teradata.Generator.createable_sql-266"><a href="#Teradata.Generator.createable_sql-266"><span class="linenos">266</span></a> <span class="n">this_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Teradata.Generator.createable_sql-267"><a href="#Teradata.Generator.createable_sql-267"><span class="linenos">267</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this_name</span><span class="si">}{</span><span class="n">this_properties</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this_schema</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Teradata.Generator.createable_sql-268"><a href="#Teradata.Generator.createable_sql-268"><span class="linenos">268</span></a> -</span><span id="Teradata.Generator.createable_sql-269"><a href="#Teradata.Generator.createable_sql-269"><span class="linenos">269</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">locations</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.createable_sql-258"><a href="#Teradata.Generator.createable_sql-258"><span class="linenos">258</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.createable_sql-259"><a href="#Teradata.Generator.createable_sql-259"><span class="linenos">259</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Teradata.Generator.createable_sql-260"><a href="#Teradata.Generator.createable_sql-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"TABLE"</span> <span class="ow">and</span> <span class="n">locations</span><span class="o">.</span><span class="n">get</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_NAME</span><span class="p">):</span> +</span><span id="Teradata.Generator.createable_sql-261"><a href="#Teradata.Generator.createable_sql-261"><span class="linenos">261</span></a> <span class="n">this_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Teradata.Generator.createable_sql-262"><a href="#Teradata.Generator.createable_sql-262"><span class="linenos">262</span></a> <span class="n">this_properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Teradata.Generator.createable_sql-263"><a href="#Teradata.Generator.createable_sql-263"><span class="linenos">263</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">locations</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_NAME</span><span class="p">]),</span> +</span><span id="Teradata.Generator.createable_sql-264"><a href="#Teradata.Generator.createable_sql-264"><span class="linenos">264</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Teradata.Generator.createable_sql-265"><a href="#Teradata.Generator.createable_sql-265"><span class="linenos">265</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> +</span><span id="Teradata.Generator.createable_sql-266"><a href="#Teradata.Generator.createable_sql-266"><span class="linenos">266</span></a> <span class="p">)</span> +</span><span id="Teradata.Generator.createable_sql-267"><a href="#Teradata.Generator.createable_sql-267"><span class="linenos">267</span></a> <span class="n">this_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Teradata.Generator.createable_sql-268"><a href="#Teradata.Generator.createable_sql-268"><span class="linenos">268</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this_name</span><span class="si">}{</span><span class="n">this_properties</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this_schema</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Teradata.Generator.createable_sql-269"><a href="#Teradata.Generator.createable_sql-269"><span class="linenos">269</span></a> +</span><span id="Teradata.Generator.createable_sql-270"><a href="#Teradata.Generator.createable_sql-270"><span class="linenos">270</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">locations</span><span class="p">)</span> </span></pre></div> |