diff options
Diffstat (limited to 'docs/sqlglot/dialects/teradata.html')
-rw-r--r-- | docs/sqlglot/dialects/teradata.html | 1745 |
1 files changed, 955 insertions, 790 deletions
diff --git a/docs/sqlglot/dialects/teradata.html b/docs/sqlglot/dialects/teradata.html index cc40233..fbdf6e5 100644 --- a/docs/sqlglot/dialects/teradata.html +++ b/docs/sqlglot/dialects/teradata.html @@ -151,6 +151,12 @@ <a class="function" href="#Teradata.Generator.createable_sql">createable_sql</a> </li> <li> + <a class="function" href="#Teradata.Generator.extract_sql">extract_sql</a> + </li> + <li> + <a class="function" href="#Teradata.Generator.interval_sql">interval_sql</a> + </li> + <li> <a class="variable" href="#Teradata.Generator.SELECT_KINDS">SELECT_KINDS</a> </li> <li> @@ -260,269 +266,319 @@ </span><span id="L-13"><a href="#L-13"><span class="linenos"> 13</span></a><span class="kn">from</span> <span class="nn">sqlglot.tokens</span> <span class="kn">import</span> <span class="n">TokenType</span> </span><span id="L-14"><a href="#L-14"><span class="linenos"> 14</span></a> </span><span id="L-15"><a href="#L-15"><span class="linenos"> 15</span></a> -</span><span id="L-16"><a href="#L-16"><span class="linenos"> 16</span></a><span class="k">class</span> <span class="nc">Teradata</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="n">SUPPORTS_SEMI_ANTI_JOIN</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> <span class="n">TYPED_DIVISION</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a> -</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> <span class="s2">"Y4"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> <span class="s2">"M4"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a> <span class="s2">"M3"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a> <span class="s2">"M"</span><span class="p">:</span> <span class="s2">"%-M"</span><span class="p">,</span> -</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="s2">"MMM"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="L-30"><a href="#L-30"><span class="linenos"> 30</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="s2">"D3"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> -</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="s2">"DDD"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> -</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="s2">"H"</span><span class="p">:</span> <span class="s2">"%-H"</span><span class="p">,</span> -</span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"%-S"</span><span class="p">,</span> -</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a> <span class="s2">"SSSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="s2">"E"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> <span class="s2">"EE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> <span class="s2">"E3"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="s2">"E4"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> -</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a> <span class="s2">"EEE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="s2">"EEEE"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> -</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> <span class="p">}</span> -</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a> -</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> -</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Comparison-Operators-and-Functions/Comparison-Operators/ANSI-Compliance</span> -</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Arithmetic-Trigonometric-Hyperbolic-Operators/Functions</span> -</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> -</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="s2">"**"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</span><span class="p">,</span> -</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> <span class="s2">"^="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="s2">"BYTEINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a> <span class="s2">"COLLECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> <span class="s2">"DEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> -</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="s2">"EQ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> <span class="s2">"GE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> -</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="s2">"GT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> -</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="s2">"HELP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="s2">"INS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> -</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="s2">"LE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> -</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="s2">"LT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> -</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="s2">"MINUS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> -</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="s2">"MOD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> -</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="s2">"NE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="s2">"NOT="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> -</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> <span class="s2">"SEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> -</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="s2">"ST_GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> -</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> -</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="s2">"UPD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> -</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="p">}</span> -</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> -</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="c1"># Teradata does not support % as a modulo operator</span> -</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">}</span> -</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"%"</span><span class="p">)</span> -</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> -</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</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-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="n">TABLESAMPLE_CSV</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> -</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> -</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> -</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_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">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="s2">"KANJI1_KANJISJIS_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">"KANJI1_SBC_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">"KANJISJIS_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">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> -</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="s2">"LOCALE_TO_UNICODE"</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_GRAPHIC"</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_GRAPHIC_PadGraphic"</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_GRAPHIC_VarGraphic"</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_KANJI1_KanjiEBCDIC"</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_KANJI1_KanjiEUC"</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_KANJI1_KANJISJIS"</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_KANJI1_SBC"</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_KANJISJIS"</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_LATIN"</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_LOCALE"</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_FoldSpace"</span><span class="p">,</span> -</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> -</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> -</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> -</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> -</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> -</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> -</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="p">}</span> -</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> -</span><span id="L-120"><a href="#L-120"><span class="linenos">120</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-121"><a href="#L-121"><span class="linenos">121</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-122"><a href="#L-122"><span class="linenos">122</span></a> -</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-124"><a href="#L-124"><span class="linenos">124</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-125"><a href="#L-125"><span class="linenos">125</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-126"><a href="#L-126"><span class="linenos">126</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-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="p">),</span> -</span><span id="L-128"><a href="#L-128"><span class="linenos">128</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-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="p">}</span> -</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> -</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-132"><a href="#L-132"><span class="linenos">132</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-133"><a href="#L-133"><span class="linenos">133</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-134"><a href="#L-134"><span class="linenos">134</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-135"><a href="#L-135"><span class="linenos">135</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-136"><a href="#L-136"><span class="linenos">136</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-137"><a href="#L-137"><span class="linenos">137</span></a> <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="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="n">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-16"><a href="#L-16"><span class="linenos"> 16</span></a><span class="k">def</span> <span class="nf">_date_add_sql</span><span class="p">(</span> +</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="n">kind</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Literal</span><span class="p">[</span><span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">],</span> +</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Teradata</span><span class="o">.</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Teradata</span><span class="o">.</span><span class="n">Generator</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">DateAdd</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</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-21"><a href="#L-21"><span class="linenos"> 21</span></a> <span class="n">unit</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">"unit"</span><span class="p">)</span> +</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a> +</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Cannot add non literal"</span><span class="p">)</span> +</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a> +</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="k">if</span> <span class="n">value</span><span class="o">.</span><span class="n">is_negative</span><span class="p">:</span> +</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="n">kind_to_op</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"+"</span><span class="p">:</span> <span class="s2">"-"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">:</span> <span class="s2">"+"</span><span class="p">}</span> +</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">name</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span> +</span><span id="L-30"><a href="#L-30"><span class="linenos"> 30</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> <span class="n">kind_to_op</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"+"</span><span class="p">:</span> <span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">:</span> <span class="s2">"-"</span><span class="p">}</span> +</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> <span class="n">value</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"is_string"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> +</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> +</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind_to_op</span><span class="p">[</span><span class="n">kind</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">value</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> +</span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="k">return</span> <span class="n">func</span> +</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> +</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> +</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a><span class="k">class</span> <span class="nc">Teradata</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> +</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a> <span class="n">SUPPORTS_SEMI_ANTI_JOIN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="n">TYPED_DIVISION</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> +</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a> <span class="s2">"Y4"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> <span class="s2">"M4"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a> <span class="s2">"M3"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> <span class="s2">"M"</span><span class="p">:</span> <span class="s2">"%-M"</span><span class="p">,</span> +</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <span class="s2">"MMM"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="s2">"D3"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> +</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a> <span class="s2">"DDD"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> +</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> <span class="s2">"H"</span><span class="p">:</span> <span class="s2">"%-H"</span><span class="p">,</span> +</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"%-S"</span><span class="p">,</span> +</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="s2">"SSSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="s2">"E"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="s2">"EE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="s2">"E3"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="s2">"E4"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> +</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="s2">"EEE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="s2">"EEEE"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> +</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="p">}</span> +</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> +</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> +</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Comparison-Operators-and-Functions/Comparison-Operators/ANSI-Compliance</span> +</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Arithmetic-Trigonometric-Hyperbolic-Operators/Functions</span> +</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> +</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="s2">"**"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</span><span class="p">,</span> +</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> <span class="s2">"^="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="s2">"BYTEINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="s2">"COLLECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="s2">"DEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> +</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="s2">"EQ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="s2">"GE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> +</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="s2">"GT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> +</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> <span class="s2">"HELP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="s2">"INS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> +</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="s2">"LE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> +</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="s2">"LT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> +</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="s2">"MINUS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> +</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="s2">"MOD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> +</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="s2">"NE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="s2">"NOT="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> +</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> <span class="s2">"SEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> +</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="s2">"ST_GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> +</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="s2">"UPD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> +</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="p">}</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> +</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="c1"># Teradata does not support % as a modulo operator</span> +</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">}</span> +</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"%"</span><span class="p">)</span> +</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a> +</span><span id="L-104"><a href="#L-104"><span class="linenos">104</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-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="n">TABLESAMPLE_CSV</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> +</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> +</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> +</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="s2">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="s2">"KANJI1_KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="s2">"KANJI1_SBC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="s2">"KANJISJIS_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="s2">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> +</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="s2">"LOCALE_TO_UNICODE"</span><span class="p">,</span> +</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="s2">"UNICODE_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_PadGraphic"</span><span class="p">,</span> +</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_VarGraphic"</span><span class="p">,</span> +</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEBCDIC"</span><span class="p">,</span> +</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEUC"</span><span class="p">,</span> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="s2">"UNICODE_TO_KANJI1_KANJISJIS"</span><span class="p">,</span> +</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="s2">"UNICODE_TO_KANJI1_SBC"</span><span class="p">,</span> +</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="s2">"UNICODE_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> <span class="s2">"UNICODE_TO_LATIN"</span><span class="p">,</span> +</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="s2">"UNICODE_TO_LOCALE"</span><span class="p">,</span> +</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="s2">"UNICODE_TO_UNICODE_FoldSpace"</span><span class="p">,</span> +</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> +</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> +</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> +</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> +</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> +</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> </span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> <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">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-144"><a href="#L-144"><span class="linenos">144</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-143"><a href="#L-143"><span class="linenos">143</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-144"><a href="#L-144"><span class="linenos">144</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-145"><a href="#L-145"><span class="linenos">145</span></a> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="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-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 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">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-150"><a href="#L-150"><span class="linenos">150</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-151"><a href="#L-151"><span class="linenos">151</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-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</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-154"><a href="#L-154"><span class="linenos">154</span></a> -</span><span id="L-155"><a href="#L-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 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-156"><a href="#L-156"><span class="linenos">156</span></a> -</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="L-158"><a href="#L-158"><span class="linenos">158</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-159"><a href="#L-159"><span class="linenos">159</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-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> -</span><span id="L-163"><a href="#L-163"><span class="linenos">163</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-164"><a href="#L-164"><span class="linenos">164</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-165"><a href="#L-165"><span class="linenos">165</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-166"><a href="#L-166"><span class="linenos">166</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-167"><a href="#L-167"><span class="linenos">167</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-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="p">},</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <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">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-172"><a href="#L-172"><span class="linenos">172</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-173"><a href="#L-173"><span class="linenos">173</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-174"><a href="#L-174"><span class="linenos">174</span></a> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</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-176"><a href="#L-176"><span class="linenos">176</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-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="o">**</span><span class="n">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-148"><a href="#L-148"><span class="linenos">148</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-149"><a href="#L-149"><span class="linenos">149</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-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="p">),</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span 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-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="p">}</span> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</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="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-156"><a href="#L-156"><span class="linenos">156</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-157"><a href="#L-157"><span class="linenos">157</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-158"><a href="#L-158"><span class="linenos">158</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-159"><a href="#L-159"><span class="linenos">159</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-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="p">}</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</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-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="p">}</span> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</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-167"><a href="#L-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_conjunction</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="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-170"><a href="#L-170"><span class="linenos">170</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-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">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-173"><a href="#L-173"><span class="linenos">173</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-174"><a href="#L-174"><span class="linenos">174</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-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</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-177"><a href="#L-177"><span class="linenos">177</span></a> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</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-178"><a href="#L-178"><span class="linenos">178</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-179"><a href="#L-179"><span class="linenos">179</span></a> -</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="k">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-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-190"><a href="#L-190"><span class="linenos">190</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-191"><a href="#L-191"><span class="linenos">191</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-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="p">}</span> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos">181</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-182"><a href="#L-182"><span class="linenos">182</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-183"><a href="#L-183"><span class="linenos">183</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-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</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-187"><a href="#L-187"><span class="linenos">187</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-188"><a href="#L-188"><span class="linenos">188</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-189"><a href="#L-189"><span class="linenos">189</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-190"><a href="#L-190"><span class="linenos">190</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-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 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">PROPERTIES_LOCATION</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">PROPERTIES_LOCATION</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">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-197"><a href="#L-197"><span class="linenos">197</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-198"><a href="#L-198"><span class="linenos">198</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-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="p">}</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</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-195"><a href="#L-195"><span class="linenos">195</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-196"><a href="#L-196"><span class="linenos">196</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-197"><a href="#L-197"><span class="linenos">197</span></a> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</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-199"><a href="#L-199"><span class="linenos">199</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-200"><a href="#L-200"><span class="linenos">200</span></a> -</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</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-203"><a href="#L-203"><span class="linenos">203</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-204"><a href="#L-204"><span class="linenos">204</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-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</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-207"><a href="#L-207"><span class="linenos">207</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-208"><a href="#L-208"><span class="linenos">208</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-209"><a href="#L-209"><span class="linenos">209</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-210"><a href="#L-210"><span class="linenos">210</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-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="p">),</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos">212</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-213"><a href="#L-213"><span class="linenos">213</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-214"><a href="#L-214"><span class="linenos">214</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-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToNumber</span><span class="p">:</span> <span class="n">to_number_with_nls_param</span><span class="p">,</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</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-217"><a href="#L-217"><span class="linenos">217</span></a> <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">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-220"><a href="#L-220"><span class="linenos">220</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-221"><a href="#L-221"><span class="linenos">221</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-222"><a href="#L-222"><span class="linenos">222</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-223"><a href="#L-223"><span class="linenos">223</span></a> -</span><span id="L-224"><a href="#L-224"><span class="linenos">224</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-225"><a href="#L-225"><span class="linenos">225</span></a> -</span><span id="L-226"><a href="#L-226"><span class="linenos">226</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-227"><a href="#L-227"><span class="linenos">227</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-228"><a href="#L-228"><span class="linenos">228</span></a> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</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-232"><a href="#L-232"><span class="linenos">232</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-233"><a href="#L-233"><span class="linenos">233</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-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</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-236"><a href="#L-236"><span class="linenos">236</span></a> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</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-238"><a href="#L-238"><span class="linenos">238</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-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="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</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-242"><a href="#L-242"><span class="linenos">242</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-243"><a href="#L-243"><span class="linenos">243</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-244"><a href="#L-244"><span class="linenos">244</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-245"><a href="#L-245"><span class="linenos">245</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-246"><a href="#L-246"><span class="linenos">246</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-247"><a href="#L-247"><span class="linenos">247</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-248"><a href="#L-248"><span class="linenos">248</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-249"><a href="#L-249"><span class="linenos">249</span></a> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</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-251"><a href="#L-251"><span class="linenos">251</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-252"><a href="#L-252"><span class="linenos">252</span></a> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</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-254"><a href="#L-254"><span class="linenos">254</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-255"><a href="#L-255"><span class="linenos">255</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-256"><a href="#L-256"><span class="linenos">256</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-257"><a href="#L-257"><span class="linenos">257</span></a> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</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-259"><a href="#L-259"><span class="linenos">259</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-260"><a href="#L-260"><span class="linenos">260</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-261"><a href="#L-261"><span class="linenos">261</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-262"><a href="#L-262"><span class="linenos">262</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-263"><a href="#L-263"><span class="linenos">263</span></a> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</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-265"><a href="#L-265"><span class="linenos">265</span></a> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</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-267"><a href="#L-267"><span class="linenos">267</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-268"><a href="#L-268"><span class="linenos">268</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-269"><a href="#L-269"><span class="linenos">269</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-270"><a href="#L-270"><span class="linenos">270</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-271"><a href="#L-271"><span class="linenos">271</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-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="p">)</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</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-276"><a href="#L-276"><span class="linenos">276</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-201"><a href="#L-201"><span class="linenos">201</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-202"><a href="#L-202"><span class="linenos">202</span></a> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="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-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> +</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</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-214"><a href="#L-214"><span class="linenos">214</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-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"DOUBLE PRECISION"</span><span class="p">,</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="p">}</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</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-220"><a href="#L-220"><span class="linenos">220</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-221"><a href="#L-221"><span class="linenos">221</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-222"><a href="#L-222"><span class="linenos">222</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-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="p">}</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> +</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos">226</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-227"><a href="#L-227"><span class="linenos">227</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-228"><a href="#L-228"><span class="linenos">228</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-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</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-231"><a href="#L-231"><span class="linenos">231</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-232"><a href="#L-232"><span class="linenos">232</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-233"><a href="#L-233"><span class="linenos">233</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-234"><a href="#L-234"><span class="linenos">234</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-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="p">),</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</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-237"><a href="#L-237"><span class="linenos">237</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-238"><a href="#L-238"><span class="linenos">238</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-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToNumber</span><span class="p">:</span> <span class="n">to_number_with_nls_param</span><span class="p">,</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</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-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"+"</span><span class="p">),</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"-"</span><span class="p">),</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quarter</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"QUARTER"</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="p">}</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</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-248"><a href="#L-248"><span class="linenos">248</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-249"><a href="#L-249"><span class="linenos">249</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-250"><a href="#L-250"><span class="linenos">250</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-251"><a href="#L-251"><span class="linenos">251</span></a> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</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-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">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-255"><a href="#L-255"><span class="linenos">255</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-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">tablesample_sql</span><span class="p">(</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</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-260"><a href="#L-260"><span class="linenos">260</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-261"><a href="#L-261"><span class="linenos">261</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-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</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-264"><a href="#L-264"><span class="linenos">264</span></a> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</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-266"><a href="#L-266"><span class="linenos">266</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-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="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</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-270"><a href="#L-270"><span class="linenos">270</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-271"><a href="#L-271"><span class="linenos">271</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-272"><a href="#L-272"><span class="linenos">272</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-273"><a href="#L-273"><span class="linenos">273</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-274"><a href="#L-274"><span class="linenos">274</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-275"><a href="#L-275"><span class="linenos">275</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-276"><a href="#L-276"><span class="linenos">276</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-277"><a href="#L-277"><span class="linenos">277</span></a> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</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-278"><a href="#L-278"><span class="linenos">278</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-279"><a href="#L-279"><span class="linenos">279</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-280"><a href="#L-280"><span class="linenos">280</span></a> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</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-282"><a href="#L-282"><span class="linenos">282</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-283"><a href="#L-283"><span class="linenos">283</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-284"><a href="#L-284"><span class="linenos">284</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-285"><a href="#L-285"><span class="linenos">285</span></a> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</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-287"><a href="#L-287"><span class="linenos">287</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-288"><a href="#L-288"><span class="linenos">288</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-289"><a href="#L-289"><span class="linenos">289</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-290"><a href="#L-290"><span class="linenos">290</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-291"><a href="#L-291"><span class="linenos">291</span></a> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</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-293"><a href="#L-293"><span class="linenos">293</span></a> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</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-295"><a href="#L-295"><span class="linenos">295</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-296"><a href="#L-296"><span class="linenos">296</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-297"><a href="#L-297"><span class="linenos">297</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-298"><a href="#L-298"><span class="linenos">298</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-299"><a href="#L-299"><span class="linenos">299</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-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="p">)</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos">303</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-304"><a href="#L-304"><span class="linenos">304</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-305"><a href="#L-305"><span class="linenos">305</span></a> +</span><span id="L-306"><a href="#L-306"><span class="linenos">306</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-307"><a href="#L-307"><span class="linenos">307</span></a> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="k">def</span> <span class="nf">extract_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">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</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-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="k">if</span> <span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"QUARTER"</span><span class="p">:</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">extract_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">to_char</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"to_char"</span><span class="p">,</span> <span class="n">expression</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"Q"</span><span class="p">))</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">to_char</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">))</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> +</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="k">elif</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"QUARTER"</span><span class="p">):</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> +</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -538,269 +594,296 @@ </div> <a class="headerlink" href="#Teradata"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata-17"><a href="#Teradata-17"><span class="linenos"> 17</span></a><span class="k">class</span> <span class="nc">Teradata</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="Teradata-18"><a href="#Teradata-18"><span class="linenos"> 18</span></a> <span class="n">SUPPORTS_SEMI_ANTI_JOIN</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-19"><a href="#Teradata-19"><span class="linenos"> 19</span></a> <span class="n">TYPED_DIVISION</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata-20"><a href="#Teradata-20"><span class="linenos"> 20</span></a> -</span><span id="Teradata-21"><a href="#Teradata-21"><span class="linenos"> 21</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-22"><a href="#Teradata-22"><span class="linenos"> 22</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="Teradata-23"><a href="#Teradata-23"><span class="linenos"> 23</span></a> <span class="s2">"Y4"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="Teradata-24"><a href="#Teradata-24"><span class="linenos"> 24</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="Teradata-25"><a href="#Teradata-25"><span class="linenos"> 25</span></a> <span class="s2">"M4"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="Teradata-26"><a href="#Teradata-26"><span class="linenos"> 26</span></a> <span class="s2">"M3"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="Teradata-27"><a href="#Teradata-27"><span class="linenos"> 27</span></a> <span class="s2">"M"</span><span class="p">:</span> <span class="s2">"%-M"</span><span class="p">,</span> -</span><span id="Teradata-28"><a href="#Teradata-28"><span class="linenos"> 28</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="Teradata-29"><a href="#Teradata-29"><span class="linenos"> 29</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="Teradata-30"><a href="#Teradata-30"><span class="linenos"> 30</span></a> <span class="s2">"MMM"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="Teradata-31"><a href="#Teradata-31"><span class="linenos"> 31</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="Teradata-32"><a href="#Teradata-32"><span class="linenos"> 32</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Teradata-33"><a href="#Teradata-33"><span class="linenos"> 33</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Teradata-34"><a href="#Teradata-34"><span class="linenos"> 34</span></a> <span class="s2">"D3"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> -</span><span id="Teradata-35"><a href="#Teradata-35"><span class="linenos"> 35</span></a> <span class="s2">"DDD"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> -</span><span id="Teradata-36"><a href="#Teradata-36"><span class="linenos"> 36</span></a> <span class="s2">"H"</span><span class="p">:</span> <span class="s2">"%-H"</span><span class="p">,</span> -</span><span id="Teradata-37"><a href="#Teradata-37"><span class="linenos"> 37</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="Teradata-38"><a href="#Teradata-38"><span class="linenos"> 38</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="Teradata-39"><a href="#Teradata-39"><span class="linenos"> 39</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"%-S"</span><span class="p">,</span> -</span><span id="Teradata-40"><a href="#Teradata-40"><span class="linenos"> 40</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="Teradata-41"><a href="#Teradata-41"><span class="linenos"> 41</span></a> <span class="s2">"SSSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Teradata-42"><a href="#Teradata-42"><span class="linenos"> 42</span></a> <span class="s2">"E"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Teradata-43"><a href="#Teradata-43"><span class="linenos"> 43</span></a> <span class="s2">"EE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Teradata-44"><a href="#Teradata-44"><span class="linenos"> 44</span></a> <span class="s2">"E3"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Teradata-45"><a href="#Teradata-45"><span class="linenos"> 45</span></a> <span class="s2">"E4"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> -</span><span id="Teradata-46"><a href="#Teradata-46"><span class="linenos"> 46</span></a> <span class="s2">"EEE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Teradata-47"><a href="#Teradata-47"><span class="linenos"> 47</span></a> <span class="s2">"EEEE"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> -</span><span id="Teradata-48"><a href="#Teradata-48"><span class="linenos"> 48</span></a> <span class="p">}</span> -</span><span id="Teradata-49"><a href="#Teradata-49"><span class="linenos"> 49</span></a> -</span><span id="Teradata-50"><a href="#Teradata-50"><span class="linenos"> 50</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> -</span><span id="Teradata-51"><a href="#Teradata-51"><span class="linenos"> 51</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Comparison-Operators-and-Functions/Comparison-Operators/ANSI-Compliance</span> -</span><span id="Teradata-52"><a href="#Teradata-52"><span class="linenos"> 52</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Arithmetic-Trigonometric-Hyperbolic-Operators/Functions</span> -</span><span id="Teradata-53"><a href="#Teradata-53"><span class="linenos"> 53</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-54"><a href="#Teradata-54"><span class="linenos"> 54</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> -</span><span id="Teradata-55"><a href="#Teradata-55"><span class="linenos"> 55</span></a> <span class="s2">"**"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</span><span class="p">,</span> -</span><span id="Teradata-56"><a href="#Teradata-56"><span class="linenos"> 56</span></a> <span class="s2">"^="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="Teradata-57"><a href="#Teradata-57"><span class="linenos"> 57</span></a> <span class="s2">"BYTEINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="Teradata-58"><a href="#Teradata-58"><span class="linenos"> 58</span></a> <span class="s2">"COLLECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="Teradata-59"><a href="#Teradata-59"><span class="linenos"> 59</span></a> <span class="s2">"DEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> -</span><span id="Teradata-60"><a href="#Teradata-60"><span class="linenos"> 60</span></a> <span class="s2">"EQ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="Teradata-61"><a href="#Teradata-61"><span class="linenos"> 61</span></a> <span class="s2">"GE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> -</span><span id="Teradata-62"><a href="#Teradata-62"><span class="linenos"> 62</span></a> <span class="s2">"GT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> -</span><span id="Teradata-63"><a href="#Teradata-63"><span class="linenos"> 63</span></a> <span class="s2">"HELP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="Teradata-64"><a href="#Teradata-64"><span class="linenos"> 64</span></a> <span class="s2">"INS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> -</span><span id="Teradata-65"><a href="#Teradata-65"><span class="linenos"> 65</span></a> <span class="s2">"LE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> -</span><span id="Teradata-66"><a href="#Teradata-66"><span class="linenos"> 66</span></a> <span class="s2">"LT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> -</span><span id="Teradata-67"><a href="#Teradata-67"><span class="linenos"> 67</span></a> <span class="s2">"MINUS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> -</span><span id="Teradata-68"><a href="#Teradata-68"><span class="linenos"> 68</span></a> <span class="s2">"MOD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> -</span><span id="Teradata-69"><a href="#Teradata-69"><span class="linenos"> 69</span></a> <span class="s2">"NE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="Teradata-70"><a href="#Teradata-70"><span class="linenos"> 70</span></a> <span class="s2">"NOT="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="Teradata-71"><a href="#Teradata-71"><span class="linenos"> 71</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> -</span><span id="Teradata-72"><a href="#Teradata-72"><span class="linenos"> 72</span></a> <span class="s2">"SEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> -</span><span id="Teradata-73"><a href="#Teradata-73"><span class="linenos"> 73</span></a> <span class="s2">"ST_GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> -</span><span id="Teradata-74"><a href="#Teradata-74"><span class="linenos"> 74</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> -</span><span id="Teradata-75"><a href="#Teradata-75"><span class="linenos"> 75</span></a> <span class="s2">"UPD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> -</span><span id="Teradata-76"><a href="#Teradata-76"><span class="linenos"> 76</span></a> <span class="p">}</span> -</span><span id="Teradata-77"><a href="#Teradata-77"><span class="linenos"> 77</span></a> -</span><span id="Teradata-78"><a href="#Teradata-78"><span class="linenos"> 78</span></a> <span class="c1"># Teradata does not support % as a modulo operator</span> -</span><span id="Teradata-79"><a href="#Teradata-79"><span class="linenos"> 79</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">}</span> -</span><span id="Teradata-80"><a href="#Teradata-80"><span class="linenos"> 80</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"%"</span><span class="p">)</span> -</span><span id="Teradata-81"><a href="#Teradata-81"><span class="linenos"> 81</span></a> -</span><span id="Teradata-82"><a href="#Teradata-82"><span class="linenos"> 82</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-83"><a href="#Teradata-83"><span class="linenos"> 83</span></a> <span class="n">TABLESAMPLE_CSV</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata-84"><a href="#Teradata-84"><span class="linenos"> 84</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-85"><a href="#Teradata-85"><span class="linenos"> 85</span></a> -</span><span id="Teradata-86"><a href="#Teradata-86"><span class="linenos"> 86</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-87"><a href="#Teradata-87"><span class="linenos"> 87</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata-88"><a href="#Teradata-88"><span class="linenos"> 88</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> -</span><span id="Teradata-89"><a href="#Teradata-89"><span class="linenos"> 89</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-90"><a href="#Teradata-90"><span class="linenos"> 90</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> -</span><span id="Teradata-91"><a href="#Teradata-91"><span class="linenos"> 91</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_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">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-93"><a href="#Teradata-93"><span class="linenos"> 93</span></a> <span class="s2">"KANJI1_KANJISJIS_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">"KANJI1_SBC_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">"KANJISJIS_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">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> -</span><span id="Teradata-97"><a href="#Teradata-97"><span class="linenos"> 97</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-98"><a href="#Teradata-98"><span class="linenos"> 98</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> -</span><span id="Teradata-99"><a href="#Teradata-99"><span class="linenos"> 99</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> -</span><span id="Teradata-100"><a href="#Teradata-100"><span class="linenos">100</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> -</span><span id="Teradata-101"><a href="#Teradata-101"><span class="linenos">101</span></a> <span class="s2">"LOCALE_TO_UNICODE"</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_GRAPHIC"</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_GRAPHIC_PadGraphic"</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_GRAPHIC_VarGraphic"</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_KANJI1_KanjiEBCDIC"</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_KANJI1_KanjiEUC"</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_KANJI1_KANJISJIS"</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_KANJI1_SBC"</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_KANJISJIS"</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_LATIN"</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_LOCALE"</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_FoldSpace"</span><span class="p">,</span> -</span><span id="Teradata-113"><a href="#Teradata-113"><span class="linenos">113</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> -</span><span id="Teradata-114"><a href="#Teradata-114"><span class="linenos">114</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> -</span><span id="Teradata-115"><a href="#Teradata-115"><span class="linenos">115</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> -</span><span id="Teradata-116"><a href="#Teradata-116"><span class="linenos">116</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> -</span><span id="Teradata-117"><a href="#Teradata-117"><span class="linenos">117</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> -</span><span id="Teradata-118"><a href="#Teradata-118"><span class="linenos">118</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> -</span><span id="Teradata-119"><a href="#Teradata-119"><span class="linenos">119</span></a> <span class="p">}</span> -</span><span id="Teradata-120"><a href="#Teradata-120"><span class="linenos">120</span></a> -</span><span id="Teradata-121"><a href="#Teradata-121"><span class="linenos">121</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-122"><a href="#Teradata-122"><span class="linenos">122</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-123"><a href="#Teradata-123"><span class="linenos">123</span></a> -</span><span id="Teradata-124"><a href="#Teradata-124"><span class="linenos">124</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-125"><a href="#Teradata-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">STATEMENT_PARSERS</span><span class="p">,</span> -</span><span id="Teradata-126"><a href="#Teradata-126"><span class="linenos">126</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-127"><a href="#Teradata-127"><span class="linenos">127</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-128"><a href="#Teradata-128"><span class="linenos">128</span></a> <span class="p">),</span> -</span><span id="Teradata-129"><a href="#Teradata-129"><span class="linenos">129</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-130"><a href="#Teradata-130"><span class="linenos">130</span></a> <span class="p">}</span> -</span><span id="Teradata-131"><a href="#Teradata-131"><span class="linenos">131</span></a> -</span><span id="Teradata-132"><a href="#Teradata-132"><span class="linenos">132</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-133"><a href="#Teradata-133"><span class="linenos">133</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-134"><a href="#Teradata-134"><span class="linenos">134</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-135"><a href="#Teradata-135"><span class="linenos">135</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-136"><a href="#Teradata-136"><span class="linenos">136</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-137"><a href="#Teradata-137"><span class="linenos">137</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-138"><a href="#Teradata-138"><span class="linenos">138</span></a> <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="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-141"><a href="#Teradata-141"><span class="linenos">141</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata-40"><a href="#Teradata-40"><span class="linenos"> 40</span></a><span class="k">class</span> <span class="nc">Teradata</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> +</span><span id="Teradata-41"><a href="#Teradata-41"><span class="linenos"> 41</span></a> <span class="n">SUPPORTS_SEMI_ANTI_JOIN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-42"><a href="#Teradata-42"><span class="linenos"> 42</span></a> <span class="n">TYPED_DIVISION</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Teradata-43"><a href="#Teradata-43"><span class="linenos"> 43</span></a> +</span><span id="Teradata-44"><a href="#Teradata-44"><span class="linenos"> 44</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-45"><a href="#Teradata-45"><span class="linenos"> 45</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="Teradata-46"><a href="#Teradata-46"><span class="linenos"> 46</span></a> <span class="s2">"Y4"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="Teradata-47"><a href="#Teradata-47"><span class="linenos"> 47</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="Teradata-48"><a href="#Teradata-48"><span class="linenos"> 48</span></a> <span class="s2">"M4"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="Teradata-49"><a href="#Teradata-49"><span class="linenos"> 49</span></a> <span class="s2">"M3"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="Teradata-50"><a href="#Teradata-50"><span class="linenos"> 50</span></a> <span class="s2">"M"</span><span class="p">:</span> <span class="s2">"%-M"</span><span class="p">,</span> +</span><span id="Teradata-51"><a href="#Teradata-51"><span class="linenos"> 51</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="Teradata-52"><a href="#Teradata-52"><span class="linenos"> 52</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="Teradata-53"><a href="#Teradata-53"><span class="linenos"> 53</span></a> <span class="s2">"MMM"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="Teradata-54"><a href="#Teradata-54"><span class="linenos"> 54</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="Teradata-55"><a href="#Teradata-55"><span class="linenos"> 55</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Teradata-56"><a href="#Teradata-56"><span class="linenos"> 56</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Teradata-57"><a href="#Teradata-57"><span class="linenos"> 57</span></a> <span class="s2">"D3"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> +</span><span id="Teradata-58"><a href="#Teradata-58"><span class="linenos"> 58</span></a> <span class="s2">"DDD"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> +</span><span id="Teradata-59"><a href="#Teradata-59"><span class="linenos"> 59</span></a> <span class="s2">"H"</span><span class="p">:</span> <span class="s2">"%-H"</span><span class="p">,</span> +</span><span id="Teradata-60"><a href="#Teradata-60"><span class="linenos"> 60</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="Teradata-61"><a href="#Teradata-61"><span class="linenos"> 61</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="Teradata-62"><a href="#Teradata-62"><span class="linenos"> 62</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"%-S"</span><span class="p">,</span> +</span><span id="Teradata-63"><a href="#Teradata-63"><span class="linenos"> 63</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="Teradata-64"><a href="#Teradata-64"><span class="linenos"> 64</span></a> <span class="s2">"SSSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Teradata-65"><a href="#Teradata-65"><span class="linenos"> 65</span></a> <span class="s2">"E"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Teradata-66"><a href="#Teradata-66"><span class="linenos"> 66</span></a> <span class="s2">"EE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Teradata-67"><a href="#Teradata-67"><span class="linenos"> 67</span></a> <span class="s2">"E3"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Teradata-68"><a href="#Teradata-68"><span class="linenos"> 68</span></a> <span class="s2">"E4"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> +</span><span id="Teradata-69"><a href="#Teradata-69"><span class="linenos"> 69</span></a> <span class="s2">"EEE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Teradata-70"><a href="#Teradata-70"><span class="linenos"> 70</span></a> <span class="s2">"EEEE"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> +</span><span id="Teradata-71"><a href="#Teradata-71"><span class="linenos"> 71</span></a> <span class="p">}</span> +</span><span id="Teradata-72"><a href="#Teradata-72"><span class="linenos"> 72</span></a> +</span><span id="Teradata-73"><a href="#Teradata-73"><span class="linenos"> 73</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> +</span><span id="Teradata-74"><a href="#Teradata-74"><span class="linenos"> 74</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Comparison-Operators-and-Functions/Comparison-Operators/ANSI-Compliance</span> +</span><span id="Teradata-75"><a href="#Teradata-75"><span class="linenos"> 75</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Arithmetic-Trigonometric-Hyperbolic-Operators/Functions</span> +</span><span id="Teradata-76"><a href="#Teradata-76"><span class="linenos"> 76</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-77"><a href="#Teradata-77"><span class="linenos"> 77</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> +</span><span id="Teradata-78"><a href="#Teradata-78"><span class="linenos"> 78</span></a> <span class="s2">"**"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</span><span class="p">,</span> +</span><span id="Teradata-79"><a href="#Teradata-79"><span class="linenos"> 79</span></a> <span class="s2">"^="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="Teradata-80"><a href="#Teradata-80"><span class="linenos"> 80</span></a> <span class="s2">"BYTEINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="Teradata-81"><a href="#Teradata-81"><span class="linenos"> 81</span></a> <span class="s2">"COLLECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="Teradata-82"><a href="#Teradata-82"><span class="linenos"> 82</span></a> <span class="s2">"DEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> +</span><span id="Teradata-83"><a href="#Teradata-83"><span class="linenos"> 83</span></a> <span class="s2">"EQ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="Teradata-84"><a href="#Teradata-84"><span class="linenos"> 84</span></a> <span class="s2">"GE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> +</span><span id="Teradata-85"><a href="#Teradata-85"><span class="linenos"> 85</span></a> <span class="s2">"GT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> +</span><span id="Teradata-86"><a href="#Teradata-86"><span class="linenos"> 86</span></a> <span class="s2">"HELP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="Teradata-87"><a href="#Teradata-87"><span class="linenos"> 87</span></a> <span class="s2">"INS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> +</span><span id="Teradata-88"><a href="#Teradata-88"><span class="linenos"> 88</span></a> <span class="s2">"LE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> +</span><span id="Teradata-89"><a href="#Teradata-89"><span class="linenos"> 89</span></a> <span class="s2">"LT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> +</span><span id="Teradata-90"><a href="#Teradata-90"><span class="linenos"> 90</span></a> <span class="s2">"MINUS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> +</span><span id="Teradata-91"><a href="#Teradata-91"><span class="linenos"> 91</span></a> <span class="s2">"MOD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> +</span><span id="Teradata-92"><a href="#Teradata-92"><span class="linenos"> 92</span></a> <span class="s2">"NE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="Teradata-93"><a href="#Teradata-93"><span class="linenos"> 93</span></a> <span class="s2">"NOT="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="Teradata-94"><a href="#Teradata-94"><span class="linenos"> 94</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> +</span><span id="Teradata-95"><a href="#Teradata-95"><span class="linenos"> 95</span></a> <span class="s2">"SEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> +</span><span id="Teradata-96"><a href="#Teradata-96"><span class="linenos"> 96</span></a> <span class="s2">"ST_GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> +</span><span id="Teradata-97"><a href="#Teradata-97"><span class="linenos"> 97</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> +</span><span id="Teradata-98"><a href="#Teradata-98"><span class="linenos"> 98</span></a> <span class="s2">"UPD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> +</span><span id="Teradata-99"><a href="#Teradata-99"><span class="linenos"> 99</span></a> <span class="p">}</span> +</span><span id="Teradata-100"><a href="#Teradata-100"><span class="linenos">100</span></a> +</span><span id="Teradata-101"><a href="#Teradata-101"><span class="linenos">101</span></a> <span class="c1"># Teradata does not support % as a modulo operator</span> +</span><span id="Teradata-102"><a href="#Teradata-102"><span class="linenos">102</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">}</span> +</span><span id="Teradata-103"><a href="#Teradata-103"><span class="linenos">103</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"%"</span><span class="p">)</span> +</span><span id="Teradata-104"><a href="#Teradata-104"><span class="linenos">104</span></a> +</span><span id="Teradata-105"><a href="#Teradata-105"><span class="linenos">105</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-106"><a href="#Teradata-106"><span class="linenos">106</span></a> <span class="n">TABLESAMPLE_CSV</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Teradata-107"><a href="#Teradata-107"><span class="linenos">107</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-108"><a href="#Teradata-108"><span class="linenos">108</span></a> +</span><span id="Teradata-109"><a href="#Teradata-109"><span class="linenos">109</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-110"><a href="#Teradata-110"><span class="linenos">110</span></a> <span class="s2">"GRAPHIC_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata-111"><a href="#Teradata-111"><span class="linenos">111</span></a> <span class="s2">"GRAPHIC_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata-112"><a href="#Teradata-112"><span class="linenos">112</span></a> <span class="s2">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-113"><a href="#Teradata-113"><span class="linenos">113</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> +</span><span id="Teradata-114"><a href="#Teradata-114"><span class="linenos">114</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-115"><a href="#Teradata-115"><span class="linenos">115</span></a> <span class="s2">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-116"><a href="#Teradata-116"><span class="linenos">116</span></a> <span class="s2">"KANJI1_KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-117"><a href="#Teradata-117"><span class="linenos">117</span></a> <span class="s2">"KANJI1_SBC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-118"><a href="#Teradata-118"><span class="linenos">118</span></a> <span class="s2">"KANJISJIS_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata-119"><a href="#Teradata-119"><span class="linenos">119</span></a> <span class="s2">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata-120"><a href="#Teradata-120"><span class="linenos">120</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-121"><a href="#Teradata-121"><span class="linenos">121</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata-122"><a href="#Teradata-122"><span class="linenos">122</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata-123"><a href="#Teradata-123"><span class="linenos">123</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-124"><a href="#Teradata-124"><span class="linenos">124</span></a> <span class="s2">"LOCALE_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata-125"><a href="#Teradata-125"><span class="linenos">125</span></a> <span class="s2">"UNICODE_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata-126"><a href="#Teradata-126"><span class="linenos">126</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_PadGraphic"</span><span class="p">,</span> +</span><span id="Teradata-127"><a href="#Teradata-127"><span class="linenos">127</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_VarGraphic"</span><span class="p">,</span> +</span><span id="Teradata-128"><a href="#Teradata-128"><span class="linenos">128</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEBCDIC"</span><span class="p">,</span> +</span><span id="Teradata-129"><a href="#Teradata-129"><span class="linenos">129</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEUC"</span><span class="p">,</span> +</span><span id="Teradata-130"><a href="#Teradata-130"><span class="linenos">130</span></a> <span class="s2">"UNICODE_TO_KANJI1_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata-131"><a href="#Teradata-131"><span class="linenos">131</span></a> <span class="s2">"UNICODE_TO_KANJI1_SBC"</span><span class="p">,</span> +</span><span id="Teradata-132"><a href="#Teradata-132"><span class="linenos">132</span></a> <span class="s2">"UNICODE_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata-133"><a href="#Teradata-133"><span class="linenos">133</span></a> <span class="s2">"UNICODE_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata-134"><a href="#Teradata-134"><span class="linenos">134</span></a> <span class="s2">"UNICODE_TO_LOCALE"</span><span class="p">,</span> +</span><span id="Teradata-135"><a href="#Teradata-135"><span class="linenos">135</span></a> <span class="s2">"UNICODE_TO_UNICODE_FoldSpace"</span><span class="p">,</span> +</span><span id="Teradata-136"><a href="#Teradata-136"><span class="linenos">136</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> +</span><span id="Teradata-137"><a href="#Teradata-137"><span class="linenos">137</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> +</span><span id="Teradata-138"><a href="#Teradata-138"><span class="linenos">138</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> +</span><span id="Teradata-139"><a href="#Teradata-139"><span class="linenos">139</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> +</span><span id="Teradata-140"><a href="#Teradata-140"><span class="linenos">140</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> +</span><span id="Teradata-141"><a href="#Teradata-141"><span class="linenos">141</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> </span><span id="Teradata-142"><a href="#Teradata-142"><span class="linenos">142</span></a> <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">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-145"><a href="#Teradata-145"><span class="linenos">145</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-144"><a href="#Teradata-144"><span class="linenos">144</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-145"><a href="#Teradata-145"><span class="linenos">145</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-146"><a href="#Teradata-146"><span class="linenos">146</span></a> -</span><span id="Teradata-147"><a href="#Teradata-147"><span class="linenos">147</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-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 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">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-151"><a href="#Teradata-151"><span class="linenos">151</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-152"><a href="#Teradata-152"><span class="linenos">152</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-153"><a href="#Teradata-153"><span class="linenos">153</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Teradata-154"><a href="#Teradata-154"><span class="linenos">154</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-155"><a href="#Teradata-155"><span class="linenos">155</span></a> -</span><span id="Teradata-156"><a href="#Teradata-156"><span class="linenos">156</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-157"><a href="#Teradata-157"><span class="linenos">157</span></a> -</span><span id="Teradata-158"><a href="#Teradata-158"><span class="linenos">158</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="Teradata-159"><a href="#Teradata-159"><span class="linenos">159</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-160"><a href="#Teradata-160"><span class="linenos">160</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-161"><a href="#Teradata-161"><span class="linenos">161</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-162"><a href="#Teradata-162"><span class="linenos">162</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="Teradata-163"><a href="#Teradata-163"><span class="linenos">163</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> -</span><span id="Teradata-164"><a href="#Teradata-164"><span class="linenos">164</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-165"><a href="#Teradata-165"><span class="linenos">165</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-166"><a href="#Teradata-166"><span class="linenos">166</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-167"><a href="#Teradata-167"><span class="linenos">167</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-168"><a href="#Teradata-168"><span class="linenos">168</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-169"><a href="#Teradata-169"><span class="linenos">169</span></a> <span class="p">},</span> -</span><span id="Teradata-170"><a href="#Teradata-170"><span class="linenos">170</span></a> <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">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-173"><a href="#Teradata-173"><span class="linenos">173</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-174"><a href="#Teradata-174"><span class="linenos">174</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-175"><a href="#Teradata-175"><span class="linenos">175</span></a> -</span><span id="Teradata-176"><a href="#Teradata-176"><span class="linenos">176</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-177"><a href="#Teradata-177"><span class="linenos">177</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-147"><a href="#Teradata-147"><span class="linenos">147</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-148"><a href="#Teradata-148"><span class="linenos">148</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-149"><a href="#Teradata-149"><span class="linenos">149</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-150"><a href="#Teradata-150"><span class="linenos">150</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-151"><a href="#Teradata-151"><span class="linenos">151</span></a> <span class="p">),</span> +</span><span id="Teradata-152"><a href="#Teradata-152"><span class="linenos">152</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-153"><a href="#Teradata-153"><span class="linenos">153</span></a> <span class="p">}</span> +</span><span id="Teradata-154"><a href="#Teradata-154"><span class="linenos">154</span></a> +</span><span id="Teradata-155"><a href="#Teradata-155"><span class="linenos">155</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</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="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-157"><a href="#Teradata-157"><span class="linenos">157</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-158"><a href="#Teradata-158"><span class="linenos">158</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-159"><a href="#Teradata-159"><span class="linenos">159</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-160"><a href="#Teradata-160"><span class="linenos">160</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-161"><a href="#Teradata-161"><span class="linenos">161</span></a> <span class="p">}</span> +</span><span id="Teradata-162"><a href="#Teradata-162"><span class="linenos">162</span></a> +</span><span id="Teradata-163"><a href="#Teradata-163"><span class="linenos">163</span></a> <span class="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-164"><a href="#Teradata-164"><span class="linenos">164</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-165"><a href="#Teradata-165"><span class="linenos">165</span></a> <span class="p">}</span> +</span><span id="Teradata-166"><a href="#Teradata-166"><span class="linenos">166</span></a> +</span><span id="Teradata-167"><a href="#Teradata-167"><span class="linenos">167</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-168"><a href="#Teradata-168"><span class="linenos">168</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-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="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-171"><a href="#Teradata-171"><span class="linenos">171</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-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">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-174"><a href="#Teradata-174"><span class="linenos">174</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-175"><a href="#Teradata-175"><span class="linenos">175</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-176"><a href="#Teradata-176"><span class="linenos">176</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Teradata-177"><a href="#Teradata-177"><span class="linenos">177</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-178"><a href="#Teradata-178"><span class="linenos">178</span></a> -</span><span id="Teradata-179"><a href="#Teradata-179"><span class="linenos">179</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-179"><a href="#Teradata-179"><span class="linenos">179</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-180"><a href="#Teradata-180"><span class="linenos">180</span></a> -</span><span id="Teradata-181"><a href="#Teradata-181"><span class="linenos">181</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-182"><a href="#Teradata-182"><span class="linenos">182</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata-183"><a href="#Teradata-183"><span class="linenos">183</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-184"><a href="#Teradata-184"><span class="linenos">184</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-185"><a href="#Teradata-185"><span class="linenos">185</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-186"><a href="#Teradata-186"><span class="linenos">186</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> -</span><span id="Teradata-187"><a href="#Teradata-187"><span class="linenos">187</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata-188"><a href="#Teradata-188"><span class="linenos">188</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata-189"><a href="#Teradata-189"><span class="linenos">189</span></a> -</span><span id="Teradata-190"><a href="#Teradata-190"><span class="linenos">190</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-191"><a href="#Teradata-191"><span class="linenos">191</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-192"><a href="#Teradata-192"><span class="linenos">192</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-193"><a href="#Teradata-193"><span class="linenos">193</span></a> <span class="p">}</span> +</span><span id="Teradata-181"><a href="#Teradata-181"><span class="linenos">181</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="Teradata-182"><a href="#Teradata-182"><span class="linenos">182</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-183"><a href="#Teradata-183"><span class="linenos">183</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-184"><a href="#Teradata-184"><span class="linenos">184</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-185"><a href="#Teradata-185"><span class="linenos">185</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="Teradata-186"><a href="#Teradata-186"><span class="linenos">186</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> +</span><span id="Teradata-187"><a href="#Teradata-187"><span class="linenos">187</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-188"><a href="#Teradata-188"><span class="linenos">188</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-189"><a href="#Teradata-189"><span class="linenos">189</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-190"><a href="#Teradata-190"><span class="linenos">190</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-191"><a href="#Teradata-191"><span class="linenos">191</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-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 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">PROPERTIES_LOCATION</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">PROPERTIES_LOCATION</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">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-198"><a href="#Teradata-198"><span class="linenos">198</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-199"><a href="#Teradata-199"><span class="linenos">199</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-200"><a href="#Teradata-200"><span class="linenos">200</span></a> <span class="p">}</span> +</span><span id="Teradata-195"><a href="#Teradata-195"><span class="linenos">195</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-196"><a href="#Teradata-196"><span class="linenos">196</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-197"><a href="#Teradata-197"><span class="linenos">197</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-198"><a href="#Teradata-198"><span class="linenos">198</span></a> +</span><span id="Teradata-199"><a href="#Teradata-199"><span class="linenos">199</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-200"><a href="#Teradata-200"><span class="linenos">200</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-201"><a href="#Teradata-201"><span class="linenos">201</span></a> -</span><span id="Teradata-202"><a href="#Teradata-202"><span class="linenos">202</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata-203"><a href="#Teradata-203"><span class="linenos">203</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-204"><a href="#Teradata-204"><span class="linenos">204</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-205"><a href="#Teradata-205"><span class="linenos">205</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-206"><a href="#Teradata-206"><span class="linenos">206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> -</span><span id="Teradata-207"><a href="#Teradata-207"><span class="linenos">207</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-208"><a href="#Teradata-208"><span class="linenos">208</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-209"><a href="#Teradata-209"><span class="linenos">209</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-210"><a href="#Teradata-210"><span class="linenos">210</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-211"><a href="#Teradata-211"><span class="linenos">211</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-212"><a href="#Teradata-212"><span class="linenos">212</span></a> <span class="p">),</span> -</span><span id="Teradata-213"><a href="#Teradata-213"><span class="linenos">213</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-214"><a href="#Teradata-214"><span class="linenos">214</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-215"><a href="#Teradata-215"><span class="linenos">215</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-216"><a href="#Teradata-216"><span class="linenos">216</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToNumber</span><span class="p">:</span> <span class="n">to_number_with_nls_param</span><span class="p">,</span> -</span><span id="Teradata-217"><a href="#Teradata-217"><span class="linenos">217</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-218"><a href="#Teradata-218"><span class="linenos">218</span></a> <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">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-221"><a href="#Teradata-221"><span class="linenos">221</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-222"><a href="#Teradata-222"><span class="linenos">222</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-223"><a href="#Teradata-223"><span class="linenos">223</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-224"><a href="#Teradata-224"><span class="linenos">224</span></a> -</span><span id="Teradata-225"><a href="#Teradata-225"><span class="linenos">225</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-226"><a href="#Teradata-226"><span class="linenos">226</span></a> -</span><span id="Teradata-227"><a href="#Teradata-227"><span class="linenos">227</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-228"><a href="#Teradata-228"><span class="linenos">228</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-229"><a href="#Teradata-229"><span class="linenos">229</span></a> -</span><span id="Teradata-230"><a href="#Teradata-230"><span class="linenos">230</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Teradata-231"><a href="#Teradata-231"><span class="linenos">231</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Teradata-232"><a href="#Teradata-232"><span class="linenos">232</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-233"><a href="#Teradata-233"><span class="linenos">233</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-234"><a href="#Teradata-234"><span class="linenos">234</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-235"><a href="#Teradata-235"><span class="linenos">235</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata-236"><a href="#Teradata-236"><span class="linenos">236</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-237"><a href="#Teradata-237"><span class="linenos">237</span></a> -</span><span id="Teradata-238"><a href="#Teradata-238"><span class="linenos">238</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-239"><a href="#Teradata-239"><span class="linenos">239</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-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="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="Teradata-242"><a href="#Teradata-242"><span class="linenos">242</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-243"><a href="#Teradata-243"><span class="linenos">243</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-244"><a href="#Teradata-244"><span class="linenos">244</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-245"><a href="#Teradata-245"><span class="linenos">245</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-246"><a href="#Teradata-246"><span class="linenos">246</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-247"><a href="#Teradata-247"><span class="linenos">247</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-248"><a href="#Teradata-248"><span class="linenos">248</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-249"><a href="#Teradata-249"><span class="linenos">249</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-250"><a href="#Teradata-250"><span class="linenos">250</span></a> -</span><span id="Teradata-251"><a href="#Teradata-251"><span class="linenos">251</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-252"><a href="#Teradata-252"><span class="linenos">252</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-253"><a href="#Teradata-253"><span class="linenos">253</span></a> -</span><span id="Teradata-254"><a href="#Teradata-254"><span class="linenos">254</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-255"><a href="#Teradata-255"><span class="linenos">255</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-256"><a href="#Teradata-256"><span class="linenos">256</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-257"><a href="#Teradata-257"><span class="linenos">257</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-258"><a href="#Teradata-258"><span class="linenos">258</span></a> -</span><span id="Teradata-259"><a href="#Teradata-259"><span class="linenos">259</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-260"><a href="#Teradata-260"><span class="linenos">260</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-261"><a href="#Teradata-261"><span class="linenos">261</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-262"><a href="#Teradata-262"><span class="linenos">262</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-263"><a href="#Teradata-263"><span class="linenos">263</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-264"><a href="#Teradata-264"><span class="linenos">264</span></a> -</span><span id="Teradata-265"><a href="#Teradata-265"><span class="linenos">265</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-266"><a href="#Teradata-266"><span class="linenos">266</span></a> -</span><span id="Teradata-267"><a href="#Teradata-267"><span class="linenos">267</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-268"><a href="#Teradata-268"><span class="linenos">268</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-269"><a href="#Teradata-269"><span class="linenos">269</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-270"><a href="#Teradata-270"><span class="linenos">270</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-271"><a href="#Teradata-271"><span class="linenos">271</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-272"><a href="#Teradata-272"><span class="linenos">272</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-273"><a href="#Teradata-273"><span class="linenos">273</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Teradata-274"><a href="#Teradata-274"><span class="linenos">274</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> -</span><span id="Teradata-275"><a href="#Teradata-275"><span class="linenos">275</span></a> <span class="p">)</span> -</span><span id="Teradata-276"><a href="#Teradata-276"><span class="linenos">276</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-277"><a href="#Teradata-277"><span class="linenos">277</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-202"><a href="#Teradata-202"><span class="linenos">202</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-203"><a href="#Teradata-203"><span class="linenos">203</span></a> +</span><span id="Teradata-204"><a href="#Teradata-204"><span class="linenos">204</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-205"><a href="#Teradata-205"><span class="linenos">205</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Teradata-206"><a href="#Teradata-206"><span class="linenos">206</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-207"><a href="#Teradata-207"><span class="linenos">207</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-208"><a href="#Teradata-208"><span class="linenos">208</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-209"><a href="#Teradata-209"><span class="linenos">209</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> +</span><span id="Teradata-210"><a href="#Teradata-210"><span class="linenos">210</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata-211"><a href="#Teradata-211"><span class="linenos">211</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Teradata-212"><a href="#Teradata-212"><span class="linenos">212</span></a> +</span><span id="Teradata-213"><a href="#Teradata-213"><span class="linenos">213</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-214"><a href="#Teradata-214"><span class="linenos">214</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-215"><a href="#Teradata-215"><span class="linenos">215</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-216"><a href="#Teradata-216"><span class="linenos">216</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"DOUBLE PRECISION"</span><span class="p">,</span> +</span><span id="Teradata-217"><a href="#Teradata-217"><span class="linenos">217</span></a> <span class="p">}</span> +</span><span id="Teradata-218"><a href="#Teradata-218"><span class="linenos">218</span></a> +</span><span id="Teradata-219"><a href="#Teradata-219"><span class="linenos">219</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-220"><a href="#Teradata-220"><span class="linenos">220</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-221"><a href="#Teradata-221"><span class="linenos">221</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-222"><a href="#Teradata-222"><span class="linenos">222</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-223"><a href="#Teradata-223"><span class="linenos">223</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-224"><a href="#Teradata-224"><span class="linenos">224</span></a> <span class="p">}</span> +</span><span id="Teradata-225"><a href="#Teradata-225"><span class="linenos">225</span></a> +</span><span id="Teradata-226"><a href="#Teradata-226"><span class="linenos">226</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata-227"><a href="#Teradata-227"><span class="linenos">227</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-228"><a href="#Teradata-228"><span class="linenos">228</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-229"><a href="#Teradata-229"><span class="linenos">229</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-230"><a href="#Teradata-230"><span class="linenos">230</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> +</span><span id="Teradata-231"><a href="#Teradata-231"><span class="linenos">231</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-232"><a href="#Teradata-232"><span class="linenos">232</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-233"><a href="#Teradata-233"><span class="linenos">233</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-234"><a href="#Teradata-234"><span class="linenos">234</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-235"><a href="#Teradata-235"><span class="linenos">235</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-236"><a href="#Teradata-236"><span class="linenos">236</span></a> <span class="p">),</span> +</span><span id="Teradata-237"><a href="#Teradata-237"><span class="linenos">237</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-238"><a href="#Teradata-238"><span class="linenos">238</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-239"><a href="#Teradata-239"><span class="linenos">239</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-240"><a href="#Teradata-240"><span class="linenos">240</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToNumber</span><span class="p">:</span> <span class="n">to_number_with_nls_param</span><span class="p">,</span> +</span><span id="Teradata-241"><a href="#Teradata-241"><span class="linenos">241</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-242"><a href="#Teradata-242"><span class="linenos">242</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="Teradata-243"><a href="#Teradata-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"+"</span><span class="p">),</span> +</span><span id="Teradata-244"><a href="#Teradata-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"-"</span><span class="p">),</span> +</span><span id="Teradata-245"><a href="#Teradata-245"><span class="linenos">245</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quarter</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"QUARTER"</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> +</span><span id="Teradata-246"><a href="#Teradata-246"><span class="linenos">246</span></a> <span class="p">}</span> +</span><span id="Teradata-247"><a href="#Teradata-247"><span class="linenos">247</span></a> +</span><span id="Teradata-248"><a href="#Teradata-248"><span class="linenos">248</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-249"><a href="#Teradata-249"><span class="linenos">249</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-250"><a href="#Teradata-250"><span class="linenos">250</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-251"><a href="#Teradata-251"><span class="linenos">251</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-252"><a href="#Teradata-252"><span class="linenos">252</span></a> +</span><span id="Teradata-253"><a href="#Teradata-253"><span class="linenos">253</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-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">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-256"><a href="#Teradata-256"><span class="linenos">256</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-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">tablesample_sql</span><span class="p">(</span> +</span><span id="Teradata-259"><a href="#Teradata-259"><span class="linenos">259</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Teradata-260"><a href="#Teradata-260"><span class="linenos">260</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-261"><a href="#Teradata-261"><span class="linenos">261</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-262"><a href="#Teradata-262"><span class="linenos">262</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-263"><a href="#Teradata-263"><span class="linenos">263</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-264"><a href="#Teradata-264"><span class="linenos">264</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-265"><a href="#Teradata-265"><span class="linenos">265</span></a> +</span><span id="Teradata-266"><a href="#Teradata-266"><span class="linenos">266</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-267"><a href="#Teradata-267"><span class="linenos">267</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-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="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="Teradata-270"><a href="#Teradata-270"><span class="linenos">270</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-271"><a href="#Teradata-271"><span class="linenos">271</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-272"><a href="#Teradata-272"><span class="linenos">272</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-273"><a href="#Teradata-273"><span class="linenos">273</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-274"><a href="#Teradata-274"><span class="linenos">274</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-275"><a href="#Teradata-275"><span class="linenos">275</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-276"><a href="#Teradata-276"><span class="linenos">276</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-277"><a href="#Teradata-277"><span class="linenos">277</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-278"><a href="#Teradata-278"><span class="linenos">278</span></a> -</span><span id="Teradata-279"><a href="#Teradata-279"><span class="linenos">279</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-279"><a href="#Teradata-279"><span class="linenos">279</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-280"><a href="#Teradata-280"><span class="linenos">280</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-281"><a href="#Teradata-281"><span class="linenos">281</span></a> +</span><span id="Teradata-282"><a href="#Teradata-282"><span class="linenos">282</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-283"><a href="#Teradata-283"><span class="linenos">283</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-284"><a href="#Teradata-284"><span class="linenos">284</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-285"><a href="#Teradata-285"><span class="linenos">285</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-286"><a href="#Teradata-286"><span class="linenos">286</span></a> +</span><span id="Teradata-287"><a href="#Teradata-287"><span class="linenos">287</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-288"><a href="#Teradata-288"><span class="linenos">288</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-289"><a href="#Teradata-289"><span class="linenos">289</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-290"><a href="#Teradata-290"><span class="linenos">290</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-291"><a href="#Teradata-291"><span class="linenos">291</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-292"><a href="#Teradata-292"><span class="linenos">292</span></a> +</span><span id="Teradata-293"><a href="#Teradata-293"><span class="linenos">293</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-294"><a href="#Teradata-294"><span class="linenos">294</span></a> +</span><span id="Teradata-295"><a href="#Teradata-295"><span class="linenos">295</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-296"><a href="#Teradata-296"><span class="linenos">296</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-297"><a href="#Teradata-297"><span class="linenos">297</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-298"><a href="#Teradata-298"><span class="linenos">298</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-299"><a href="#Teradata-299"><span class="linenos">299</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-300"><a href="#Teradata-300"><span class="linenos">300</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-301"><a href="#Teradata-301"><span class="linenos">301</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Teradata-302"><a href="#Teradata-302"><span class="linenos">302</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> +</span><span id="Teradata-303"><a href="#Teradata-303"><span class="linenos">303</span></a> <span class="p">)</span> +</span><span id="Teradata-304"><a href="#Teradata-304"><span class="linenos">304</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-305"><a href="#Teradata-305"><span class="linenos">305</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-306"><a href="#Teradata-306"><span class="linenos">306</span></a> +</span><span id="Teradata-307"><a href="#Teradata-307"><span class="linenos">307</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-308"><a href="#Teradata-308"><span class="linenos">308</span></a> +</span><span id="Teradata-309"><a href="#Teradata-309"><span class="linenos">309</span></a> <span class="k">def</span> <span class="nf">extract_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">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-310"><a href="#Teradata-310"><span class="linenos">310</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-311"><a href="#Teradata-311"><span class="linenos">311</span></a> <span class="k">if</span> <span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"QUARTER"</span><span class="p">:</span> +</span><span id="Teradata-312"><a href="#Teradata-312"><span class="linenos">312</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">extract_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Teradata-313"><a href="#Teradata-313"><span class="linenos">313</span></a> +</span><span id="Teradata-314"><a href="#Teradata-314"><span class="linenos">314</span></a> <span class="n">to_char</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"to_char"</span><span class="p">,</span> <span class="n">expression</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"Q"</span><span class="p">))</span> +</span><span id="Teradata-315"><a href="#Teradata-315"><span class="linenos">315</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">to_char</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">))</span> +</span><span id="Teradata-316"><a href="#Teradata-316"><span class="linenos">316</span></a> +</span><span id="Teradata-317"><a href="#Teradata-317"><span class="linenos">317</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata-318"><a href="#Teradata-318"><span class="linenos">318</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Teradata-319"><a href="#Teradata-319"><span class="linenos">319</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Teradata-320"><a href="#Teradata-320"><span class="linenos">320</span></a> +</span><span id="Teradata-321"><a href="#Teradata-321"><span class="linenos">321</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> +</span><span id="Teradata-322"><a href="#Teradata-322"><span class="linenos">322</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="Teradata-323"><a href="#Teradata-323"><span class="linenos">323</span></a> <span class="k">elif</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"QUARTER"</span><span class="p">):</span> +</span><span id="Teradata-324"><a href="#Teradata-324"><span class="linenos">324</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="Teradata-325"><a href="#Teradata-325"><span class="linenos">325</span></a> +</span><span id="Teradata-326"><a href="#Teradata-326"><span class="linenos">326</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="Teradata-327"><a href="#Teradata-327"><span class="linenos">327</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Teradata-328"><a href="#Teradata-328"><span class="linenos">328</span></a> +</span><span id="Teradata-329"><a href="#Teradata-329"><span class="linenos">329</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -1153,37 +1236,37 @@ True means <code>a / b</code> is integer division if both <code>a</code> and <co </div> <a class="headerlink" href="#Teradata.Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Tokenizer-50"><a href="#Teradata.Tokenizer-50"><span class="linenos">50</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> -</span><span id="Teradata.Tokenizer-51"><a href="#Teradata.Tokenizer-51"><span class="linenos">51</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Comparison-Operators-and-Functions/Comparison-Operators/ANSI-Compliance</span> -</span><span id="Teradata.Tokenizer-52"><a href="#Teradata.Tokenizer-52"><span class="linenos">52</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Arithmetic-Trigonometric-Hyperbolic-Operators/Functions</span> -</span><span id="Teradata.Tokenizer-53"><a href="#Teradata.Tokenizer-53"><span class="linenos">53</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Tokenizer-54"><a href="#Teradata.Tokenizer-54"><span class="linenos">54</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-55"><a href="#Teradata.Tokenizer-55"><span class="linenos">55</span></a> <span class="s2">"**"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-56"><a href="#Teradata.Tokenizer-56"><span class="linenos">56</span></a> <span class="s2">"^="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-57"><a href="#Teradata.Tokenizer-57"><span class="linenos">57</span></a> <span class="s2">"BYTEINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-58"><a href="#Teradata.Tokenizer-58"><span class="linenos">58</span></a> <span class="s2">"COLLECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-59"><a href="#Teradata.Tokenizer-59"><span class="linenos">59</span></a> <span class="s2">"DEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-60"><a href="#Teradata.Tokenizer-60"><span class="linenos">60</span></a> <span class="s2">"EQ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-61"><a href="#Teradata.Tokenizer-61"><span class="linenos">61</span></a> <span class="s2">"GE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-62"><a href="#Teradata.Tokenizer-62"><span class="linenos">62</span></a> <span class="s2">"GT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-63"><a href="#Teradata.Tokenizer-63"><span class="linenos">63</span></a> <span class="s2">"HELP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-64"><a href="#Teradata.Tokenizer-64"><span class="linenos">64</span></a> <span class="s2">"INS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-65"><a href="#Teradata.Tokenizer-65"><span class="linenos">65</span></a> <span class="s2">"LE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-66"><a href="#Teradata.Tokenizer-66"><span class="linenos">66</span></a> <span class="s2">"LT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-67"><a href="#Teradata.Tokenizer-67"><span class="linenos">67</span></a> <span class="s2">"MINUS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-68"><a href="#Teradata.Tokenizer-68"><span class="linenos">68</span></a> <span class="s2">"MOD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-69"><a href="#Teradata.Tokenizer-69"><span class="linenos">69</span></a> <span class="s2">"NE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-70"><a href="#Teradata.Tokenizer-70"><span class="linenos">70</span></a> <span class="s2">"NOT="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-71"><a href="#Teradata.Tokenizer-71"><span class="linenos">71</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-72"><a href="#Teradata.Tokenizer-72"><span class="linenos">72</span></a> <span class="s2">"SEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-73"><a href="#Teradata.Tokenizer-73"><span class="linenos">73</span></a> <span class="s2">"ST_GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-74"><a href="#Teradata.Tokenizer-74"><span class="linenos">74</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-75"><a href="#Teradata.Tokenizer-75"><span class="linenos">75</span></a> <span class="s2">"UPD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> -</span><span id="Teradata.Tokenizer-76"><a href="#Teradata.Tokenizer-76"><span class="linenos">76</span></a> <span class="p">}</span> -</span><span id="Teradata.Tokenizer-77"><a href="#Teradata.Tokenizer-77"><span class="linenos">77</span></a> -</span><span id="Teradata.Tokenizer-78"><a href="#Teradata.Tokenizer-78"><span class="linenos">78</span></a> <span class="c1"># Teradata does not support % as a modulo operator</span> -</span><span id="Teradata.Tokenizer-79"><a href="#Teradata.Tokenizer-79"><span class="linenos">79</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">}</span> -</span><span id="Teradata.Tokenizer-80"><a href="#Teradata.Tokenizer-80"><span class="linenos">80</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"%"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Tokenizer-73"><a href="#Teradata.Tokenizer-73"><span class="linenos"> 73</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> +</span><span id="Teradata.Tokenizer-74"><a href="#Teradata.Tokenizer-74"><span class="linenos"> 74</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Comparison-Operators-and-Functions/Comparison-Operators/ANSI-Compliance</span> +</span><span id="Teradata.Tokenizer-75"><a href="#Teradata.Tokenizer-75"><span class="linenos"> 75</span></a> <span class="c1"># https://docs.teradata.com/r/SQL-Functions-Operators-Expressions-and-Predicates/June-2017/Arithmetic-Trigonometric-Hyperbolic-Operators/Functions</span> +</span><span id="Teradata.Tokenizer-76"><a href="#Teradata.Tokenizer-76"><span class="linenos"> 76</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Tokenizer-77"><a href="#Teradata.Tokenizer-77"><span class="linenos"> 77</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-78"><a href="#Teradata.Tokenizer-78"><span class="linenos"> 78</span></a> <span class="s2">"**"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DSTAR</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-79"><a href="#Teradata.Tokenizer-79"><span class="linenos"> 79</span></a> <span class="s2">"^="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-80"><a href="#Teradata.Tokenizer-80"><span class="linenos"> 80</span></a> <span class="s2">"BYTEINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-81"><a href="#Teradata.Tokenizer-81"><span class="linenos"> 81</span></a> <span class="s2">"COLLECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-82"><a href="#Teradata.Tokenizer-82"><span class="linenos"> 82</span></a> <span class="s2">"DEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-83"><a href="#Teradata.Tokenizer-83"><span class="linenos"> 83</span></a> <span class="s2">"EQ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-84"><a href="#Teradata.Tokenizer-84"><span class="linenos"> 84</span></a> <span class="s2">"GE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-85"><a href="#Teradata.Tokenizer-85"><span class="linenos"> 85</span></a> <span class="s2">"GT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-86"><a href="#Teradata.Tokenizer-86"><span class="linenos"> 86</span></a> <span class="s2">"HELP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-87"><a href="#Teradata.Tokenizer-87"><span class="linenos"> 87</span></a> <span class="s2">"INS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-88"><a href="#Teradata.Tokenizer-88"><span class="linenos"> 88</span></a> <span class="s2">"LE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-89"><a href="#Teradata.Tokenizer-89"><span class="linenos"> 89</span></a> <span class="s2">"LT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-90"><a href="#Teradata.Tokenizer-90"><span class="linenos"> 90</span></a> <span class="s2">"MINUS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-91"><a href="#Teradata.Tokenizer-91"><span class="linenos"> 91</span></a> <span class="s2">"MOD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-92"><a href="#Teradata.Tokenizer-92"><span class="linenos"> 92</span></a> <span class="s2">"NE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-93"><a href="#Teradata.Tokenizer-93"><span class="linenos"> 93</span></a> <span class="s2">"NOT="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-94"><a href="#Teradata.Tokenizer-94"><span class="linenos"> 94</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-95"><a href="#Teradata.Tokenizer-95"><span class="linenos"> 95</span></a> <span class="s2">"SEL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-96"><a href="#Teradata.Tokenizer-96"><span class="linenos"> 96</span></a> <span class="s2">"ST_GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-97"><a href="#Teradata.Tokenizer-97"><span class="linenos"> 97</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-98"><a href="#Teradata.Tokenizer-98"><span class="linenos"> 98</span></a> <span class="s2">"UPD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> +</span><span id="Teradata.Tokenizer-99"><a href="#Teradata.Tokenizer-99"><span class="linenos"> 99</span></a> <span class="p">}</span> +</span><span id="Teradata.Tokenizer-100"><a href="#Teradata.Tokenizer-100"><span class="linenos">100</span></a> +</span><span id="Teradata.Tokenizer-101"><a href="#Teradata.Tokenizer-101"><span class="linenos">101</span></a> <span class="c1"># Teradata does not support % as a modulo operator</span> +</span><span id="Teradata.Tokenizer-102"><a href="#Teradata.Tokenizer-102"><span class="linenos">102</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">}</span> +</span><span id="Teradata.Tokenizer-103"><a href="#Teradata.Tokenizer-103"><span class="linenos">103</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"%"</span><span class="p">)</span> </span></pre></div> @@ -1261,104 +1344,104 @@ True means <code>a / b</code> is integer division if both <code>a</code> and <co </div> <a class="headerlink" href="#Teradata.Parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Parser-82"><a href="#Teradata.Parser-82"><span class="linenos"> 82</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-83"><a href="#Teradata.Parser-83"><span class="linenos"> 83</span></a> <span class="n">TABLESAMPLE_CSV</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata.Parser-84"><a href="#Teradata.Parser-84"><span class="linenos"> 84</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata.Parser-85"><a href="#Teradata.Parser-85"><span class="linenos"> 85</span></a> -</span><span id="Teradata.Parser-86"><a href="#Teradata.Parser-86"><span class="linenos"> 86</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</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">"GRAPHIC_TO_KANJISJIS"</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">"GRAPHIC_TO_LATIN"</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">"GRAPHIC_TO_UNICODE"</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">"GRAPHIC_TO_UNICODE_PadSpace"</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">"KANJI1_KanjiEBCDIC_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">"KANJI1_KanjiEUC_TO_UNICODE"</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">"KANJI1_KANJISJIS_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">"KANJI1_SBC_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">"KANJISJIS_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">"KANJISJIS_TO_LATIN"</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">"KANJISJIS_TO_UNICODE"</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">"LATIN_TO_GRAPHIC"</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">"LATIN_TO_KANJISJIS"</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">"LATIN_TO_UNICODE"</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">"LOCALE_TO_UNICODE"</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_GRAPHIC"</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_GRAPHIC_PadGraphic"</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_GRAPHIC_VarGraphic"</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_KANJI1_KanjiEBCDIC"</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_KANJI1_KanjiEUC"</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_KANJI1_KANJISJIS"</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_KANJI1_SBC"</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_KANJISJIS"</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_LATIN"</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_LOCALE"</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_FoldSpace"</span><span class="p">,</span> -</span><span id="Teradata.Parser-113"><a href="#Teradata.Parser-113"><span class="linenos">113</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> -</span><span id="Teradata.Parser-114"><a href="#Teradata.Parser-114"><span class="linenos">114</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> -</span><span id="Teradata.Parser-115"><a href="#Teradata.Parser-115"><span class="linenos">115</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-116"><a href="#Teradata.Parser-116"><span class="linenos">116</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> -</span><span id="Teradata.Parser-117"><a href="#Teradata.Parser-117"><span class="linenos">117</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> -</span><span id="Teradata.Parser-118"><a href="#Teradata.Parser-118"><span class="linenos">118</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> -</span><span id="Teradata.Parser-119"><a href="#Teradata.Parser-119"><span class="linenos">119</span></a> <span class="p">}</span> -</span><span id="Teradata.Parser-120"><a href="#Teradata.Parser-120"><span class="linenos">120</span></a> -</span><span id="Teradata.Parser-121"><a href="#Teradata.Parser-121"><span class="linenos">121</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-122"><a href="#Teradata.Parser-122"><span class="linenos">122</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-123"><a href="#Teradata.Parser-123"><span class="linenos">123</span></a> -</span><span id="Teradata.Parser-124"><a href="#Teradata.Parser-124"><span class="linenos">124</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Parser-125"><a href="#Teradata.Parser-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">STATEMENT_PARSERS</span><span class="p">,</span> -</span><span id="Teradata.Parser-126"><a href="#Teradata.Parser-126"><span class="linenos">126</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-127"><a href="#Teradata.Parser-127"><span class="linenos">127</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-128"><a href="#Teradata.Parser-128"><span class="linenos">128</span></a> <span class="p">),</span> -</span><span id="Teradata.Parser-129"><a href="#Teradata.Parser-129"><span class="linenos">129</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-130"><a href="#Teradata.Parser-130"><span class="linenos">130</span></a> <span class="p">}</span> -</span><span id="Teradata.Parser-131"><a href="#Teradata.Parser-131"><span class="linenos">131</span></a> -</span><span id="Teradata.Parser-132"><a href="#Teradata.Parser-132"><span class="linenos">132</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Parser-133"><a href="#Teradata.Parser-133"><span class="linenos">133</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-134"><a href="#Teradata.Parser-134"><span class="linenos">134</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-135"><a href="#Teradata.Parser-135"><span class="linenos">135</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-136"><a href="#Teradata.Parser-136"><span class="linenos">136</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-137"><a href="#Teradata.Parser-137"><span class="linenos">137</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-138"><a href="#Teradata.Parser-138"><span class="linenos">138</span></a> <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="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Parser-141"><a href="#Teradata.Parser-141"><span class="linenos">141</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Parser-105"><a href="#Teradata.Parser-105"><span class="linenos">105</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-106"><a href="#Teradata.Parser-106"><span class="linenos">106</span></a> <span class="n">TABLESAMPLE_CSV</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Teradata.Parser-107"><a href="#Teradata.Parser-107"><span class="linenos">107</span></a> <span class="n">VALUES_FOLLOWED_BY_PAREN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata.Parser-108"><a href="#Teradata.Parser-108"><span class="linenos">108</span></a> +</span><span id="Teradata.Parser-109"><a href="#Teradata.Parser-109"><span class="linenos">109</span></a> <span class="n">CHARSET_TRANSLATORS</span> <span class="o">=</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">"GRAPHIC_TO_KANJISJIS"</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">"GRAPHIC_TO_LATIN"</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">"GRAPHIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-113"><a href="#Teradata.Parser-113"><span class="linenos">113</span></a> <span class="s2">"GRAPHIC_TO_UNICODE_PadSpace"</span><span class="p">,</span> +</span><span id="Teradata.Parser-114"><a href="#Teradata.Parser-114"><span class="linenos">114</span></a> <span class="s2">"KANJI1_KanjiEBCDIC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-115"><a href="#Teradata.Parser-115"><span class="linenos">115</span></a> <span class="s2">"KANJI1_KanjiEUC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-116"><a href="#Teradata.Parser-116"><span class="linenos">116</span></a> <span class="s2">"KANJI1_KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-117"><a href="#Teradata.Parser-117"><span class="linenos">117</span></a> <span class="s2">"KANJI1_SBC_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-118"><a href="#Teradata.Parser-118"><span class="linenos">118</span></a> <span class="s2">"KANJISJIS_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-119"><a href="#Teradata.Parser-119"><span class="linenos">119</span></a> <span class="s2">"KANJISJIS_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata.Parser-120"><a href="#Teradata.Parser-120"><span class="linenos">120</span></a> <span class="s2">"KANJISJIS_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-121"><a href="#Teradata.Parser-121"><span class="linenos">121</span></a> <span class="s2">"LATIN_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-122"><a href="#Teradata.Parser-122"><span class="linenos">122</span></a> <span class="s2">"LATIN_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata.Parser-123"><a href="#Teradata.Parser-123"><span class="linenos">123</span></a> <span class="s2">"LATIN_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-124"><a href="#Teradata.Parser-124"><span class="linenos">124</span></a> <span class="s2">"LOCALE_TO_UNICODE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-125"><a href="#Teradata.Parser-125"><span class="linenos">125</span></a> <span class="s2">"UNICODE_TO_GRAPHIC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-126"><a href="#Teradata.Parser-126"><span class="linenos">126</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_PadGraphic"</span><span class="p">,</span> +</span><span id="Teradata.Parser-127"><a href="#Teradata.Parser-127"><span class="linenos">127</span></a> <span class="s2">"UNICODE_TO_GRAPHIC_VarGraphic"</span><span class="p">,</span> +</span><span id="Teradata.Parser-128"><a href="#Teradata.Parser-128"><span class="linenos">128</span></a> <span class="s2">"UNICODE_TO_KANJI1_KanjiEBCDIC"</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">"UNICODE_TO_KANJI1_KanjiEUC"</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">"UNICODE_TO_KANJI1_KANJISJIS"</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">"UNICODE_TO_KANJI1_SBC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-132"><a href="#Teradata.Parser-132"><span class="linenos">132</span></a> <span class="s2">"UNICODE_TO_KANJISJIS"</span><span class="p">,</span> +</span><span id="Teradata.Parser-133"><a href="#Teradata.Parser-133"><span class="linenos">133</span></a> <span class="s2">"UNICODE_TO_LATIN"</span><span class="p">,</span> +</span><span id="Teradata.Parser-134"><a href="#Teradata.Parser-134"><span class="linenos">134</span></a> <span class="s2">"UNICODE_TO_LOCALE"</span><span class="p">,</span> +</span><span id="Teradata.Parser-135"><a href="#Teradata.Parser-135"><span class="linenos">135</span></a> <span class="s2">"UNICODE_TO_UNICODE_FoldSpace"</span><span class="p">,</span> +</span><span id="Teradata.Parser-136"><a href="#Teradata.Parser-136"><span class="linenos">136</span></a> <span class="s2">"UNICODE_TO_UNICODE_Fullwidth"</span><span class="p">,</span> +</span><span id="Teradata.Parser-137"><a href="#Teradata.Parser-137"><span class="linenos">137</span></a> <span class="s2">"UNICODE_TO_UNICODE_Halfwidth"</span><span class="p">,</span> +</span><span id="Teradata.Parser-138"><a href="#Teradata.Parser-138"><span class="linenos">138</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-139"><a href="#Teradata.Parser-139"><span class="linenos">139</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFD"</span><span class="p">,</span> +</span><span id="Teradata.Parser-140"><a href="#Teradata.Parser-140"><span class="linenos">140</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKC"</span><span class="p">,</span> +</span><span id="Teradata.Parser-141"><a href="#Teradata.Parser-141"><span class="linenos">141</span></a> <span class="s2">"UNICODE_TO_UNICODE_NFKD"</span><span class="p">,</span> </span><span id="Teradata.Parser-142"><a href="#Teradata.Parser-142"><span class="linenos">142</span></a> <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">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-145"><a href="#Teradata.Parser-145"><span class="linenos">145</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-144"><a href="#Teradata.Parser-144"><span class="linenos">144</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-145"><a href="#Teradata.Parser-145"><span class="linenos">145</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-146"><a href="#Teradata.Parser-146"><span class="linenos">146</span></a> -</span><span id="Teradata.Parser-147"><a href="#Teradata.Parser-147"><span class="linenos">147</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-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 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">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-151"><a href="#Teradata.Parser-151"><span class="linenos">151</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-152"><a href="#Teradata.Parser-152"><span class="linenos">152</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-153"><a href="#Teradata.Parser-153"><span class="linenos">153</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Teradata.Parser-154"><a href="#Teradata.Parser-154"><span class="linenos">154</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-155"><a href="#Teradata.Parser-155"><span class="linenos">155</span></a> -</span><span id="Teradata.Parser-156"><a href="#Teradata.Parser-156"><span class="linenos">156</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-157"><a href="#Teradata.Parser-157"><span class="linenos">157</span></a> -</span><span id="Teradata.Parser-158"><a href="#Teradata.Parser-158"><span class="linenos">158</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="Teradata.Parser-159"><a href="#Teradata.Parser-159"><span class="linenos">159</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-160"><a href="#Teradata.Parser-160"><span class="linenos">160</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-161"><a href="#Teradata.Parser-161"><span class="linenos">161</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-162"><a href="#Teradata.Parser-162"><span class="linenos">162</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-163"><a href="#Teradata.Parser-163"><span class="linenos">163</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> -</span><span id="Teradata.Parser-164"><a href="#Teradata.Parser-164"><span class="linenos">164</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-165"><a href="#Teradata.Parser-165"><span class="linenos">165</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-166"><a href="#Teradata.Parser-166"><span class="linenos">166</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-167"><a href="#Teradata.Parser-167"><span class="linenos">167</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-168"><a href="#Teradata.Parser-168"><span class="linenos">168</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-169"><a href="#Teradata.Parser-169"><span class="linenos">169</span></a> <span class="p">},</span> -</span><span id="Teradata.Parser-170"><a href="#Teradata.Parser-170"><span class="linenos">170</span></a> <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">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-173"><a href="#Teradata.Parser-173"><span class="linenos">173</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-174"><a href="#Teradata.Parser-174"><span class="linenos">174</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-175"><a href="#Teradata.Parser-175"><span class="linenos">175</span></a> -</span><span id="Teradata.Parser-176"><a href="#Teradata.Parser-176"><span class="linenos">176</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-177"><a href="#Teradata.Parser-177"><span class="linenos">177</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-147"><a href="#Teradata.Parser-147"><span class="linenos">147</span></a> <span class="n">STATEMENT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Parser-148"><a href="#Teradata.Parser-148"><span class="linenos">148</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-149"><a href="#Teradata.Parser-149"><span class="linenos">149</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-150"><a href="#Teradata.Parser-150"><span class="linenos">150</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-151"><a href="#Teradata.Parser-151"><span class="linenos">151</span></a> <span class="p">),</span> +</span><span id="Teradata.Parser-152"><a href="#Teradata.Parser-152"><span class="linenos">152</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-153"><a href="#Teradata.Parser-153"><span class="linenos">153</span></a> <span class="p">}</span> +</span><span id="Teradata.Parser-154"><a href="#Teradata.Parser-154"><span class="linenos">154</span></a> +</span><span id="Teradata.Parser-155"><a href="#Teradata.Parser-155"><span class="linenos">155</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</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="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-157"><a href="#Teradata.Parser-157"><span class="linenos">157</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-158"><a href="#Teradata.Parser-158"><span class="linenos">158</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-159"><a href="#Teradata.Parser-159"><span class="linenos">159</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-160"><a href="#Teradata.Parser-160"><span class="linenos">160</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-161"><a href="#Teradata.Parser-161"><span class="linenos">161</span></a> <span class="p">}</span> +</span><span id="Teradata.Parser-162"><a href="#Teradata.Parser-162"><span class="linenos">162</span></a> +</span><span id="Teradata.Parser-163"><a href="#Teradata.Parser-163"><span class="linenos">163</span></a> <span class="n">EXPONENT</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Parser-164"><a href="#Teradata.Parser-164"><span class="linenos">164</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-165"><a href="#Teradata.Parser-165"><span class="linenos">165</span></a> <span class="p">}</span> +</span><span id="Teradata.Parser-166"><a href="#Teradata.Parser-166"><span class="linenos">166</span></a> +</span><span id="Teradata.Parser-167"><a href="#Teradata.Parser-167"><span class="linenos">167</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-168"><a href="#Teradata.Parser-168"><span class="linenos">168</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-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="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-171"><a href="#Teradata.Parser-171"><span class="linenos">171</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-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">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-174"><a href="#Teradata.Parser-174"><span class="linenos">174</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-175"><a href="#Teradata.Parser-175"><span class="linenos">175</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-176"><a href="#Teradata.Parser-176"><span class="linenos">176</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Teradata.Parser-177"><a href="#Teradata.Parser-177"><span class="linenos">177</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-178"><a href="#Teradata.Parser-178"><span class="linenos">178</span></a> -</span><span id="Teradata.Parser-179"><a href="#Teradata.Parser-179"><span class="linenos">179</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-179"><a href="#Teradata.Parser-179"><span class="linenos">179</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-180"><a href="#Teradata.Parser-180"><span class="linenos">180</span></a> +</span><span id="Teradata.Parser-181"><a href="#Teradata.Parser-181"><span class="linenos">181</span></a> <span class="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="Teradata.Parser-182"><a href="#Teradata.Parser-182"><span class="linenos">182</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-183"><a href="#Teradata.Parser-183"><span class="linenos">183</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-184"><a href="#Teradata.Parser-184"><span class="linenos">184</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-185"><a href="#Teradata.Parser-185"><span class="linenos">185</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-186"><a href="#Teradata.Parser-186"><span class="linenos">186</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> +</span><span id="Teradata.Parser-187"><a href="#Teradata.Parser-187"><span class="linenos">187</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-188"><a href="#Teradata.Parser-188"><span class="linenos">188</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-189"><a href="#Teradata.Parser-189"><span class="linenos">189</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-190"><a href="#Teradata.Parser-190"><span class="linenos">190</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-191"><a href="#Teradata.Parser-191"><span class="linenos">191</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-192"><a href="#Teradata.Parser-192"><span class="linenos">192</span></a> <span class="p">},</span> +</span><span id="Teradata.Parser-193"><a href="#Teradata.Parser-193"><span class="linenos">193</span></a> <span class="p">)</span> +</span><span id="Teradata.Parser-194"><a href="#Teradata.Parser-194"><span class="linenos">194</span></a> +</span><span id="Teradata.Parser-195"><a href="#Teradata.Parser-195"><span class="linenos">195</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-196"><a href="#Teradata.Parser-196"><span class="linenos">196</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-197"><a href="#Teradata.Parser-197"><span class="linenos">197</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-198"><a href="#Teradata.Parser-198"><span class="linenos">198</span></a> +</span><span id="Teradata.Parser-199"><a href="#Teradata.Parser-199"><span class="linenos">199</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-200"><a href="#Teradata.Parser-200"><span class="linenos">200</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-201"><a href="#Teradata.Parser-201"><span class="linenos">201</span></a> +</span><span id="Teradata.Parser-202"><a href="#Teradata.Parser-202"><span class="linenos">202</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> @@ -1407,7 +1490,7 @@ Default: 3</li> <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">{'UNICODE_TO_GRAPHIC', 'LATIN_TO_GRAPHIC', 'KANJISJIS_TO_LATIN', 'GRAPHIC_TO_LATIN', 'LATIN_TO_UNICODE', 'UNICODE_TO_UNICODE_NFC', 'LATIN_TO_KANJISJIS', 'UNICODE_TO_GRAPHIC_VarGraphic', 'UNICODE_TO_UNICODE_FoldSpace', 'KANJI1_SBC_TO_UNICODE', 'GRAPHIC_TO_KANJISJIS', 'UNICODE_TO_GRAPHIC_PadGraphic', 'KANJISJIS_TO_UNICODE', 'UNICODE_TO_KANJI1_KanjiEUC', 'UNICODE_TO_KANJI1_KANJISJIS', 'GRAPHIC_TO_UNICODE', 'UNICODE_TO_LATIN', 'KANJI1_KanjiEBCDIC_TO_UNICODE', 'KANJI1_KANJISJIS_TO_UNICODE', 'UNICODE_TO_UNICODE_Halfwidth', 'UNICODE_TO_UNICODE_NFD', 'GRAPHIC_TO_UNICODE_PadSpace', 'UNICODE_TO_KANJI1_SBC', 'UNICODE_TO_UNICODE_NFKD', 'UNICODE_TO_KANJI1_KanjiEBCDIC', 'UNICODE_TO_LOCALE', 'UNICODE_TO_KANJISJIS', 'UNICODE_TO_UNICODE_Fullwidth', 'KANJISJIS_TO_GRAPHIC', 'UNICODE_TO_UNICODE_NFKC', 'KANJI1_KanjiEUC_TO_UNICODE', 'LOCALE_TO_UNICODE'}</span> + <label class="view-value-button pdoc-button" for="Teradata.Parser.CHARSET_TRANSLATORS-view-value"></label><span class="default_value">{'GRAPHIC_TO_UNICODE_PadSpace', 'UNICODE_TO_GRAPHIC', 'KANJISJIS_TO_LATIN', 'UNICODE_TO_KANJI1_KANJISJIS', 'UNICODE_TO_UNICODE_FoldSpace', 'GRAPHIC_TO_LATIN', 'KANJI1_KANJISJIS_TO_UNICODE', 'KANJISJIS_TO_GRAPHIC', 'UNICODE_TO_UNICODE_NFKD', 'UNICODE_TO_KANJISJIS', 'LATIN_TO_UNICODE', 'UNICODE_TO_UNICODE_Halfwidth', 'LOCALE_TO_UNICODE', 'UNICODE_TO_UNICODE_Fullwidth', 'UNICODE_TO_UNICODE_NFKC', 'UNICODE_TO_UNICODE_NFC', 'GRAPHIC_TO_KANJISJIS', 'UNICODE_TO_GRAPHIC_VarGraphic', 'KANJI1_KanjiEBCDIC_TO_UNICODE', 'LATIN_TO_KANJISJIS', 'KANJI1_KanjiEUC_TO_UNICODE', 'KANJISJIS_TO_UNICODE', 'UNICODE_TO_KANJI1_KanjiEBCDIC', 'UNICODE_TO_UNICODE_NFD', 'GRAPHIC_TO_UNICODE', 'UNICODE_TO_KANJI1_SBC', 'UNICODE_TO_LATIN', 'LATIN_TO_GRAPHIC', 'UNICODE_TO_GRAPHIC_PadGraphic', 'UNICODE_TO_KANJI1_KanjiEUC', 'UNICODE_TO_LOCALE', 'KANJI1_SBC_TO_UNICODE'}</span> </div> @@ -1420,7 +1503,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.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.ILIKE: 'ILIKE'>, <TokenType.JSON: 'JSON'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.MERGE: 'MERGE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.UINT128: 'UINT128'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.INT256: 'INT256'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.XML: 'XML'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.NESTED: 'NESTED'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.VAR: 'VAR'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.IPV4: 'IPV4'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.TIME: 'TIME'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.MONEY: 'MONEY'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.FILTER: 'FILTER'>, <TokenType.LEFT: 'LEFT'>, <TokenType.UUID: 'UUID'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.INSERT: 'INSERT'>, <TokenType.INET: 'INET'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.DATE32: 'DATE32'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.DATE: 'DATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.SUPER: 'SUPER'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.MAP: 'MAP'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.IPV6: 'IPV6'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.NAME: 'NAME'>, <TokenType.ENUM: 'ENUM'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.FIRST: 'FIRST'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.NULL: 'NULL'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.BIT: 'BIT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.ROW: 'ROW'>, <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.SOME: 'SOME'>, <TokenType.CHAR: 'CHAR'>, <TokenType.XOR: 'XOR'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.LIKE: 'LIKE'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.RLIKE: 'RLIKE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.UINT256: 'UINT256'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.BINARY: 'BINARY'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.INT: 'INT'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.INT128: 'INT128'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.TABLE: 'TABLE'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.YEAR: 'YEAR'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.RANGE: 'RANGE'>, <TokenType.GLOB: 'GLOB'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.UINT: 'UINT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.ANY: 'ANY'>, <TokenType.ALL: 'ALL'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>}</span> + <label class="view-value-button pdoc-button" for="Teradata.Parser.FUNC_TOKENS-view-value"></label><span class="default_value">{<TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.LEFT: 'LEFT'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.MONEY: 'MONEY'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.FIRST: 'FIRST'>, <TokenType.YEAR: 'YEAR'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.INT128: 'INT128'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.CHAR: 'CHAR'>, <TokenType.RLIKE: 'RLIKE'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.TABLE: 'TABLE'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.GLOB: 'GLOB'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.UINT128: 'UINT128'>, <TokenType.BINARY: 'BINARY'>, <TokenType.BIT: 'BIT'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.MERGE: 'MERGE'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.INET: 'INET'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.INSERT: 'INSERT'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.IPV4: 'IPV4'>, <TokenType.SOME: 'SOME'>, <TokenType.ILIKE: 'ILIKE'>, <TokenType.RANGE: 'RANGE'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.UINT: 'UINT'>, <TokenType.SUPER: 'SUPER'>, <TokenType.JSONB: 'JSONB'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.LIKE: 'LIKE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.XML: 'XML'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.IPV6: 'IPV6'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.FILTER: 'FILTER'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.INT256: 'INT256'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.NAME: 'NAME'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.ROW: 'ROW'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.XOR: 'XOR'>, <TokenType.TIME: 'TIME'>, <TokenType.DATE32: 'DATE32'>, <TokenType.VAR: 'VAR'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.JSON: 'JSON'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.MAP: 'MAP'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.INT: 'INT'>, <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, <TokenType.ALL: 'ALL'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.ENUM: 'ENUM'>, <TokenType.ANY: 'ANY'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.DATE: 'DATE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.UINT256: 'UINT256'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.UUID: 'UUID'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.NULL: 'NULL'>, <TokenType.INDEX: 'INDEX'>}</span> </div> @@ -1471,7 +1554,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.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.JSON: 'JSON'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.MERGE: 'MERGE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.UINT128: 'UINT128'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.CASE: 'CASE'>, <TokenType.DESC: 'DESC'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.INT256: 'INT256'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.XML: 'XML'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.FINAL: 'FINAL'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.NESTED: 'NESTED'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.INDEX: 'INDEX'>, <TokenType.VAR: 'VAR'>, <TokenType.END: 'END'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.SEMI: 'SEMI'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.IPV4: 'IPV4'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.TIME: 'TIME'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.NEXT: 'NEXT'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.DELETE: 'DELETE'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.FALSE: 'FALSE'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.ROWS: 'ROWS'>, <TokenType.MONEY: 'MONEY'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.FILTER: 'FILTER'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.USE: 'USE'>, <TokenType.UUID: 'UUID'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.INET: 'INET'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.DATE32: 'DATE32'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.DATE: 'DATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.SUPER: 'SUPER'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.MAP: 'MAP'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.IPV6: 'IPV6'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.NAME: 'NAME'>, <TokenType.ENUM: 'ENUM'>, <TokenType.SHOW: 'SHOW'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.FIRST: 'FIRST'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.NULL: 'NULL'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.BIT: 'BIT'>, <TokenType.KILL: 'KILL'>, <TokenType.MODEL: 'MODEL'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.ANTI: 'ANTI'>, <TokenType.SET: 'SET'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.ASC: 'ASC'>, <TokenType.JSONB: 'JSONB'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.ROW: 'ROW'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.SOME: 'SOME'>, <TokenType.CHAR: 'CHAR'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.TRUE: 'TRUE'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.TOP: 'TOP'>, <TokenType.LOAD: 'LOAD'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.UINT256: 'UINT256'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.BINARY: 'BINARY'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.INT: 'INT'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.INT128: 'INT128'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.IS: 'IS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.KEEP: 'KEEP'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.TABLE: 'TABLE'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.YEAR: 'YEAR'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.RANGE: 'RANGE'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.UINT: 'UINT'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.ANY: 'ANY'>, <TokenType.DIV: 'DIV'>, <TokenType.ALL: 'ALL'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>}</span> + <label class="view-value-button pdoc-button" for="Teradata.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.SHOW: 'SHOW'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.USE: 'USE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.MONEY: 'MONEY'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.FIRST: 'FIRST'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.YEAR: 'YEAR'>, <TokenType.ANTI: 'ANTI'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.FINAL: 'FINAL'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.ASC: 'ASC'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.INT128: 'INT128'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.MODEL: 'MODEL'>, <TokenType.DELETE: 'DELETE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.CHAR: 'CHAR'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.TABLE: 'TABLE'>, <TokenType.CASE: 'CASE'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.NESTED: 'NESTED'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.UINT128: 'UINT128'>, <TokenType.BINARY: 'BINARY'>, <TokenType.BIT: 'BIT'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.MERGE: 'MERGE'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.INET: 'INET'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.FALSE: 'FALSE'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.ROWS: 'ROWS'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.IPV4: 'IPV4'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.SOME: 'SOME'>, <TokenType.RANGE: 'RANGE'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.NEXT: 'NEXT'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.UINT: 'UINT'>, <TokenType.DIV: 'DIV'>, <TokenType.SUPER: 'SUPER'>, <TokenType.JSONB: 'JSONB'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.TOP: 'TOP'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.KEEP: 'KEEP'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.TEXT: 'TEXT'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.XML: 'XML'>, <TokenType.LOAD: 'LOAD'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.IPV6: 'IPV6'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.FILTER: 'FILTER'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.INT256: 'INT256'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.NAME: 'NAME'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.ROW: 'ROW'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TIME: 'TIME'>, <TokenType.DATE32: 'DATE32'>, <TokenType.VAR: 'VAR'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.JSON: 'JSON'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.MAP: 'MAP'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.TRUE: 'TRUE'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.END: 'END'>, <TokenType.SEMI: 'SEMI'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.SET: 'SET'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.INT: 'INT'>, <TokenType.DESC: 'DESC'>, <TokenType.ALL: 'ALL'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.ENUM: 'ENUM'>, <TokenType.ANY: 'ANY'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.DATE: 'DATE'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.IS: 'IS'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.UINT256: 'UINT256'>, <TokenType.UUID: 'UUID'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.KILL: 'KILL'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.NULL: 'NULL'>, <TokenType.INDEX: 'INDEX'>}</span> </div> @@ -1630,105 +1713,132 @@ Default: 3</li> </div> <a class="headerlink" href="#Teradata.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator-181"><a href="#Teradata.Generator-181"><span class="linenos">181</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-182"><a href="#Teradata.Generator-182"><span class="linenos">182</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata.Generator-183"><a href="#Teradata.Generator-183"><span class="linenos">183</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata.Generator-184"><a href="#Teradata.Generator-184"><span class="linenos">184</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata.Generator-185"><a href="#Teradata.Generator-185"><span class="linenos">185</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Teradata.Generator-186"><a href="#Teradata.Generator-186"><span class="linenos">186</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> -</span><span id="Teradata.Generator-187"><a href="#Teradata.Generator-187"><span class="linenos">187</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-188"><a href="#Teradata.Generator-188"><span class="linenos">188</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Teradata.Generator-189"><a href="#Teradata.Generator-189"><span class="linenos">189</span></a> -</span><span id="Teradata.Generator-190"><a href="#Teradata.Generator-190"><span class="linenos">190</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Generator-191"><a href="#Teradata.Generator-191"><span class="linenos">191</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-192"><a href="#Teradata.Generator-192"><span class="linenos">192</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-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">PROPERTIES_LOCATION</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">PROPERTIES_LOCATION</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">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-198"><a href="#Teradata.Generator-198"><span class="linenos">198</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-199"><a href="#Teradata.Generator-199"><span class="linenos">199</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-200"><a href="#Teradata.Generator-200"><span class="linenos">200</span></a> <span class="p">}</span> -</span><span id="Teradata.Generator-201"><a href="#Teradata.Generator-201"><span class="linenos">201</span></a> -</span><span id="Teradata.Generator-202"><a href="#Teradata.Generator-202"><span class="linenos">202</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Teradata.Generator-203"><a href="#Teradata.Generator-203"><span class="linenos">203</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-204"><a href="#Teradata.Generator-204"><span class="linenos">204</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-205"><a href="#Teradata.Generator-205"><span class="linenos">205</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-206"><a href="#Teradata.Generator-206"><span class="linenos">206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> -</span><span id="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">Max</span><span class="p">:</span> <span class="n">max_or_greatest</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">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="Teradata.Generator-209"><a href="#Teradata.Generator-209"><span class="linenos">209</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-210"><a href="#Teradata.Generator-210"><span class="linenos">210</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-211"><a href="#Teradata.Generator-211"><span class="linenos">211</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-212"><a href="#Teradata.Generator-212"><span class="linenos">212</span></a> <span class="p">),</span> -</span><span id="Teradata.Generator-213"><a href="#Teradata.Generator-213"><span class="linenos">213</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-214"><a href="#Teradata.Generator-214"><span class="linenos">214</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-215"><a href="#Teradata.Generator-215"><span class="linenos">215</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-216"><a href="#Teradata.Generator-216"><span class="linenos">216</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToNumber</span><span class="p">:</span> <span class="n">to_number_with_nls_param</span><span class="p">,</span> -</span><span id="Teradata.Generator-217"><a href="#Teradata.Generator-217"><span class="linenos">217</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-218"><a href="#Teradata.Generator-218"><span class="linenos">218</span></a> <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">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-221"><a href="#Teradata.Generator-221"><span class="linenos">221</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-222"><a href="#Teradata.Generator-222"><span class="linenos">222</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-223"><a href="#Teradata.Generator-223"><span class="linenos">223</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-224"><a href="#Teradata.Generator-224"><span class="linenos">224</span></a> -</span><span id="Teradata.Generator-225"><a href="#Teradata.Generator-225"><span class="linenos">225</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-226"><a href="#Teradata.Generator-226"><span class="linenos">226</span></a> -</span><span id="Teradata.Generator-227"><a href="#Teradata.Generator-227"><span class="linenos">227</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-228"><a href="#Teradata.Generator-228"><span class="linenos">228</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-229"><a href="#Teradata.Generator-229"><span class="linenos">229</span></a> -</span><span id="Teradata.Generator-230"><a href="#Teradata.Generator-230"><span class="linenos">230</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Teradata.Generator-231"><a href="#Teradata.Generator-231"><span class="linenos">231</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Teradata.Generator-232"><a href="#Teradata.Generator-232"><span class="linenos">232</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-233"><a href="#Teradata.Generator-233"><span class="linenos">233</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-234"><a href="#Teradata.Generator-234"><span class="linenos">234</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-235"><a href="#Teradata.Generator-235"><span class="linenos">235</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Teradata.Generator-236"><a href="#Teradata.Generator-236"><span class="linenos">236</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-237"><a href="#Teradata.Generator-237"><span class="linenos">237</span></a> -</span><span id="Teradata.Generator-238"><a href="#Teradata.Generator-238"><span class="linenos">238</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-239"><a href="#Teradata.Generator-239"><span class="linenos">239</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-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="c1"># FROM before SET in Teradata UPDATE syntax</span> -</span><span id="Teradata.Generator-242"><a href="#Teradata.Generator-242"><span class="linenos">242</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-243"><a href="#Teradata.Generator-243"><span class="linenos">243</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-244"><a href="#Teradata.Generator-244"><span class="linenos">244</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-245"><a href="#Teradata.Generator-245"><span class="linenos">245</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-246"><a href="#Teradata.Generator-246"><span class="linenos">246</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-247"><a href="#Teradata.Generator-247"><span class="linenos">247</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-248"><a href="#Teradata.Generator-248"><span class="linenos">248</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-249"><a href="#Teradata.Generator-249"><span class="linenos">249</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-250"><a href="#Teradata.Generator-250"><span class="linenos">250</span></a> -</span><span id="Teradata.Generator-251"><a href="#Teradata.Generator-251"><span class="linenos">251</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-252"><a href="#Teradata.Generator-252"><span class="linenos">252</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-253"><a href="#Teradata.Generator-253"><span class="linenos">253</span></a> -</span><span id="Teradata.Generator-254"><a href="#Teradata.Generator-254"><span class="linenos">254</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-255"><a href="#Teradata.Generator-255"><span class="linenos">255</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-256"><a href="#Teradata.Generator-256"><span class="linenos">256</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-257"><a href="#Teradata.Generator-257"><span class="linenos">257</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-258"><a href="#Teradata.Generator-258"><span class="linenos">258</span></a> -</span><span id="Teradata.Generator-259"><a href="#Teradata.Generator-259"><span class="linenos">259</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-260"><a href="#Teradata.Generator-260"><span class="linenos">260</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-261"><a href="#Teradata.Generator-261"><span class="linenos">261</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-262"><a href="#Teradata.Generator-262"><span class="linenos">262</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-263"><a href="#Teradata.Generator-263"><span class="linenos">263</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-264"><a href="#Teradata.Generator-264"><span class="linenos">264</span></a> -</span><span id="Teradata.Generator-265"><a href="#Teradata.Generator-265"><span class="linenos">265</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-266"><a href="#Teradata.Generator-266"><span class="linenos">266</span></a> -</span><span id="Teradata.Generator-267"><a href="#Teradata.Generator-267"><span class="linenos">267</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-268"><a href="#Teradata.Generator-268"><span class="linenos">268</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-269"><a href="#Teradata.Generator-269"><span class="linenos">269</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-270"><a href="#Teradata.Generator-270"><span class="linenos">270</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-271"><a href="#Teradata.Generator-271"><span class="linenos">271</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-272"><a href="#Teradata.Generator-272"><span class="linenos">272</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-273"><a href="#Teradata.Generator-273"><span class="linenos">273</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-274"><a href="#Teradata.Generator-274"><span class="linenos">274</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> -</span><span id="Teradata.Generator-275"><a href="#Teradata.Generator-275"><span class="linenos">275</span></a> <span class="p">)</span> -</span><span id="Teradata.Generator-276"><a href="#Teradata.Generator-276"><span class="linenos">276</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-277"><a href="#Teradata.Generator-277"><span class="linenos">277</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator-204"><a href="#Teradata.Generator-204"><span class="linenos">204</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-205"><a href="#Teradata.Generator-205"><span class="linenos">205</span></a> <span class="n">LIMIT_IS_TOP</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Teradata.Generator-206"><a href="#Teradata.Generator-206"><span class="linenos">206</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata.Generator-207"><a href="#Teradata.Generator-207"><span class="linenos">207</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata.Generator-208"><a href="#Teradata.Generator-208"><span class="linenos">208</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Teradata.Generator-209"><a href="#Teradata.Generator-209"><span class="linenos">209</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"SAMPLE"</span> +</span><span id="Teradata.Generator-210"><a href="#Teradata.Generator-210"><span class="linenos">210</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-211"><a href="#Teradata.Generator-211"><span class="linenos">211</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Teradata.Generator-212"><a href="#Teradata.Generator-212"><span class="linenos">212</span></a> +</span><span id="Teradata.Generator-213"><a href="#Teradata.Generator-213"><span class="linenos">213</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Generator-214"><a href="#Teradata.Generator-214"><span class="linenos">214</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-215"><a href="#Teradata.Generator-215"><span class="linenos">215</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-216"><a href="#Teradata.Generator-216"><span class="linenos">216</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"DOUBLE PRECISION"</span><span class="p">,</span> +</span><span id="Teradata.Generator-217"><a href="#Teradata.Generator-217"><span class="linenos">217</span></a> <span class="p">}</span> +</span><span id="Teradata.Generator-218"><a href="#Teradata.Generator-218"><span class="linenos">218</span></a> +</span><span id="Teradata.Generator-219"><a href="#Teradata.Generator-219"><span class="linenos">219</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Generator-220"><a href="#Teradata.Generator-220"><span class="linenos">220</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-221"><a href="#Teradata.Generator-221"><span class="linenos">221</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-222"><a href="#Teradata.Generator-222"><span class="linenos">222</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-223"><a href="#Teradata.Generator-223"><span class="linenos">223</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-224"><a href="#Teradata.Generator-224"><span class="linenos">224</span></a> <span class="p">}</span> +</span><span id="Teradata.Generator-225"><a href="#Teradata.Generator-225"><span class="linenos">225</span></a> +</span><span id="Teradata.Generator-226"><a href="#Teradata.Generator-226"><span class="linenos">226</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Teradata.Generator-227"><a href="#Teradata.Generator-227"><span class="linenos">227</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-228"><a href="#Teradata.Generator-228"><span class="linenos">228</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-229"><a href="#Teradata.Generator-229"><span class="linenos">229</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-230"><a href="#Teradata.Generator-230"><span class="linenos">230</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CARDINALITY"</span><span class="p">),</span> +</span><span id="Teradata.Generator-231"><a href="#Teradata.Generator-231"><span class="linenos">231</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-232"><a href="#Teradata.Generator-232"><span class="linenos">232</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-233"><a href="#Teradata.Generator-233"><span class="linenos">233</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-234"><a href="#Teradata.Generator-234"><span class="linenos">234</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-235"><a href="#Teradata.Generator-235"><span class="linenos">235</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-236"><a href="#Teradata.Generator-236"><span class="linenos">236</span></a> <span class="p">),</span> +</span><span id="Teradata.Generator-237"><a href="#Teradata.Generator-237"><span class="linenos">237</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-238"><a href="#Teradata.Generator-238"><span class="linenos">238</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-239"><a href="#Teradata.Generator-239"><span class="linenos">239</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-240"><a href="#Teradata.Generator-240"><span class="linenos">240</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToNumber</span><span class="p">:</span> <span class="n">to_number_with_nls_param</span><span class="p">,</span> +</span><span id="Teradata.Generator-241"><a href="#Teradata.Generator-241"><span class="linenos">241</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-242"><a href="#Teradata.Generator-242"><span class="linenos">242</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="Teradata.Generator-243"><a href="#Teradata.Generator-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"+"</span><span class="p">),</span> +</span><span id="Teradata.Generator-244"><a href="#Teradata.Generator-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"-"</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">exp</span><span class="o">.</span><span class="n">Quarter</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"QUARTER"</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> +</span><span id="Teradata.Generator-246"><a href="#Teradata.Generator-246"><span class="linenos">246</span></a> <span class="p">}</span> +</span><span id="Teradata.Generator-247"><a href="#Teradata.Generator-247"><span class="linenos">247</span></a> +</span><span id="Teradata.Generator-248"><a href="#Teradata.Generator-248"><span class="linenos">248</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-249"><a href="#Teradata.Generator-249"><span class="linenos">249</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-250"><a href="#Teradata.Generator-250"><span class="linenos">250</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-251"><a href="#Teradata.Generator-251"><span class="linenos">251</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-252"><a href="#Teradata.Generator-252"><span class="linenos">252</span></a> +</span><span id="Teradata.Generator-253"><a href="#Teradata.Generator-253"><span class="linenos">253</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-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">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-256"><a href="#Teradata.Generator-256"><span class="linenos">256</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-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">tablesample_sql</span><span class="p">(</span> +</span><span id="Teradata.Generator-259"><a href="#Teradata.Generator-259"><span class="linenos">259</span></a> <span class="bp">self</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">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-261"><a href="#Teradata.Generator-261"><span class="linenos">261</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-262"><a href="#Teradata.Generator-262"><span class="linenos">262</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-263"><a href="#Teradata.Generator-263"><span class="linenos">263</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-264"><a href="#Teradata.Generator-264"><span class="linenos">264</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-265"><a href="#Teradata.Generator-265"><span class="linenos">265</span></a> +</span><span id="Teradata.Generator-266"><a href="#Teradata.Generator-266"><span class="linenos">266</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-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">"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-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="c1"># FROM before SET in Teradata UPDATE syntax</span> +</span><span id="Teradata.Generator-270"><a href="#Teradata.Generator-270"><span class="linenos">270</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-271"><a href="#Teradata.Generator-271"><span class="linenos">271</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-272"><a href="#Teradata.Generator-272"><span class="linenos">272</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-273"><a href="#Teradata.Generator-273"><span class="linenos">273</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-274"><a href="#Teradata.Generator-274"><span class="linenos">274</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-275"><a href="#Teradata.Generator-275"><span class="linenos">275</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-276"><a href="#Teradata.Generator-276"><span class="linenos">276</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-277"><a href="#Teradata.Generator-277"><span class="linenos">277</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-278"><a href="#Teradata.Generator-278"><span class="linenos">278</span></a> -</span><span id="Teradata.Generator-279"><a href="#Teradata.Generator-279"><span class="linenos">279</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.Generator-279"><a href="#Teradata.Generator-279"><span class="linenos">279</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-280"><a href="#Teradata.Generator-280"><span class="linenos">280</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-281"><a href="#Teradata.Generator-281"><span class="linenos">281</span></a> +</span><span id="Teradata.Generator-282"><a href="#Teradata.Generator-282"><span class="linenos">282</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-283"><a href="#Teradata.Generator-283"><span class="linenos">283</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-284"><a href="#Teradata.Generator-284"><span class="linenos">284</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-285"><a href="#Teradata.Generator-285"><span class="linenos">285</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-286"><a href="#Teradata.Generator-286"><span class="linenos">286</span></a> +</span><span id="Teradata.Generator-287"><a href="#Teradata.Generator-287"><span class="linenos">287</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-288"><a href="#Teradata.Generator-288"><span class="linenos">288</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-289"><a href="#Teradata.Generator-289"><span class="linenos">289</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-290"><a href="#Teradata.Generator-290"><span class="linenos">290</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-291"><a href="#Teradata.Generator-291"><span class="linenos">291</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-292"><a href="#Teradata.Generator-292"><span class="linenos">292</span></a> +</span><span id="Teradata.Generator-293"><a href="#Teradata.Generator-293"><span class="linenos">293</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-294"><a href="#Teradata.Generator-294"><span class="linenos">294</span></a> +</span><span id="Teradata.Generator-295"><a href="#Teradata.Generator-295"><span class="linenos">295</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-296"><a href="#Teradata.Generator-296"><span class="linenos">296</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-297"><a href="#Teradata.Generator-297"><span class="linenos">297</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-298"><a href="#Teradata.Generator-298"><span class="linenos">298</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-299"><a href="#Teradata.Generator-299"><span class="linenos">299</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-300"><a href="#Teradata.Generator-300"><span class="linenos">300</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-301"><a href="#Teradata.Generator-301"><span class="linenos">301</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-302"><a href="#Teradata.Generator-302"><span class="linenos">302</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> +</span><span id="Teradata.Generator-303"><a href="#Teradata.Generator-303"><span class="linenos">303</span></a> <span class="p">)</span> +</span><span id="Teradata.Generator-304"><a href="#Teradata.Generator-304"><span class="linenos">304</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-305"><a href="#Teradata.Generator-305"><span class="linenos">305</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-306"><a href="#Teradata.Generator-306"><span class="linenos">306</span></a> +</span><span id="Teradata.Generator-307"><a href="#Teradata.Generator-307"><span class="linenos">307</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.Generator-308"><a href="#Teradata.Generator-308"><span class="linenos">308</span></a> +</span><span id="Teradata.Generator-309"><a href="#Teradata.Generator-309"><span class="linenos">309</span></a> <span class="k">def</span> <span class="nf">extract_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">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-310"><a href="#Teradata.Generator-310"><span class="linenos">310</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-311"><a href="#Teradata.Generator-311"><span class="linenos">311</span></a> <span class="k">if</span> <span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"QUARTER"</span><span class="p">:</span> +</span><span id="Teradata.Generator-312"><a href="#Teradata.Generator-312"><span class="linenos">312</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">extract_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Teradata.Generator-313"><a href="#Teradata.Generator-313"><span class="linenos">313</span></a> +</span><span id="Teradata.Generator-314"><a href="#Teradata.Generator-314"><span class="linenos">314</span></a> <span class="n">to_char</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"to_char"</span><span class="p">,</span> <span class="n">expression</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"Q"</span><span class="p">))</span> +</span><span id="Teradata.Generator-315"><a href="#Teradata.Generator-315"><span class="linenos">315</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">to_char</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">))</span> +</span><span id="Teradata.Generator-316"><a href="#Teradata.Generator-316"><span class="linenos">316</span></a> +</span><span id="Teradata.Generator-317"><a href="#Teradata.Generator-317"><span class="linenos">317</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator-318"><a href="#Teradata.Generator-318"><span class="linenos">318</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Teradata.Generator-319"><a href="#Teradata.Generator-319"><span class="linenos">319</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Teradata.Generator-320"><a href="#Teradata.Generator-320"><span class="linenos">320</span></a> +</span><span id="Teradata.Generator-321"><a href="#Teradata.Generator-321"><span class="linenos">321</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> +</span><span id="Teradata.Generator-322"><a href="#Teradata.Generator-322"><span class="linenos">322</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="Teradata.Generator-323"><a href="#Teradata.Generator-323"><span class="linenos">323</span></a> <span class="k">elif</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"QUARTER"</span><span class="p">):</span> +</span><span id="Teradata.Generator-324"><a href="#Teradata.Generator-324"><span class="linenos">324</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="Teradata.Generator-325"><a href="#Teradata.Generator-325"><span class="linenos">325</span></a> +</span><span id="Teradata.Generator-326"><a href="#Teradata.Generator-326"><span class="linenos">326</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="Teradata.Generator-327"><a href="#Teradata.Generator-327"><span class="linenos">327</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Teradata.Generator-328"><a href="#Teradata.Generator-328"><span class="linenos">328</span></a> +</span><span id="Teradata.Generator-329"><a href="#Teradata.Generator-329"><span class="linenos">329</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -1861,7 +1971,7 @@ Default: True</li> <div class="attr variable"> <span class="name">TYPE_MAPPING</span> = <input id="Teradata.Generator.TYPE_MAPPING-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="Teradata.Generator.TYPE_MAPPING-view-value"></label><span class="default_value">{<Type.NCHAR: 'NCHAR'>: 'CHAR', <Type.NVARCHAR: 'NVARCHAR'>: 'VARCHAR', <Type.MEDIUMTEXT: 'MEDIUMTEXT'>: 'TEXT', <Type.LONGTEXT: 'LONGTEXT'>: 'TEXT', <Type.TINYTEXT: 'TINYTEXT'>: 'TEXT', <Type.MEDIUMBLOB: 'MEDIUMBLOB'>: 'BLOB', <Type.LONGBLOB: 'LONGBLOB'>: 'BLOB', <Type.TINYBLOB: 'TINYBLOB'>: 'BLOB', <Type.INET: 'INET'>: 'INET', <Type.GEOMETRY: 'GEOMETRY'>: 'ST_GEOMETRY'}</span> + <label class="view-value-button pdoc-button" for="Teradata.Generator.TYPE_MAPPING-view-value"></label><span class="default_value">{<Type.NCHAR: 'NCHAR'>: 'CHAR', <Type.NVARCHAR: 'NVARCHAR'>: 'VARCHAR', <Type.MEDIUMTEXT: 'MEDIUMTEXT'>: 'TEXT', <Type.LONGTEXT: 'LONGTEXT'>: 'TEXT', <Type.TINYTEXT: 'TINYTEXT'>: 'TEXT', <Type.MEDIUMBLOB: 'MEDIUMBLOB'>: 'BLOB', <Type.LONGBLOB: 'LONGBLOB'>: 'BLOB', <Type.TINYBLOB: 'TINYBLOB'>: 'BLOB', <Type.INET: 'INET'>: 'INET', <Type.GEOMETRY: 'GEOMETRY'>: 'ST_GEOMETRY', <Type.DOUBLE: 'DOUBLE'>: 'DOUBLE PRECISION'}</span> </div> @@ -1887,7 +1997,7 @@ Default: True</li> <div class="attr variable"> <span class="name">TRANSFORMS</span> = <input id="Teradata.Generator.TRANSFORMS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="Teradata.Generator.TRANSFORMS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathFilter">sqlglot.expressions.JSONPathFilter</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathRecursive">sqlglot.expressions.JSONPathRecursive</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathScript">sqlglot.expressions.JSONPathScript</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathSelector">sqlglot.expressions.JSONPathSelector</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathSlice">sqlglot.expressions.JSONPathSlice</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathUnion">sqlglot.expressions.JSONPathUnion</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathWildcard">sqlglot.expressions.JSONPathWildcard</a>'>: <function <lambda>>, <class '<a href="../expressions.html#AutoRefreshProperty">sqlglot.expressions.AutoRefreshProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#BackupProperty">sqlglot.expressions.BackupProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CaseSpecificColumnConstraint">sqlglot.expressions.CaseSpecificColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetColumnConstraint">sqlglot.expressions.CharacterSetColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetProperty">sqlglot.expressions.CharacterSetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ClusteredColumnConstraint">sqlglot.expressions.ClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CollateColumnConstraint">sqlglot.expressions.CollateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CommentColumnConstraint">sqlglot.expressions.CommentColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CopyGrantsProperty">sqlglot.expressions.CopyGrantsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DateFormatColumnConstraint">sqlglot.expressions.DateFormatColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DefaultColumnConstraint">sqlglot.expressions.DefaultColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EncodeColumnConstraint">sqlglot.expressions.EncodeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExcludeColumnConstraint">sqlglot.expressions.ExcludeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExecuteAsProperty">sqlglot.expressions.ExecuteAsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExternalProperty">sqlglot.expressions.ExternalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#GlobalProperty">sqlglot.expressions.GlobalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#HeapProperty">sqlglot.expressions.HeapProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IcebergProperty">sqlglot.expressions.IcebergProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InheritsProperty">sqlglot.expressions.InheritsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InlineLengthColumnConstraint">sqlglot.expressions.InlineLengthColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InputModelProperty">sqlglot.expressions.InputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IntervalSpan">sqlglot.expressions.IntervalSpan</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#JSONExtract">sqlglot.expressions.JSONExtract</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#JSONExtractScalar">sqlglot.expressions.JSONExtractScalar</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LanguageProperty">sqlglot.expressions.LanguageProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LocationProperty">sqlglot.expressions.LocationProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LogProperty">sqlglot.expressions.LogProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#MaterializedProperty">sqlglot.expressions.MaterializedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NonClusteredColumnConstraint">sqlglot.expressions.NonClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NoPrimaryIndexProperty">sqlglot.expressions.NoPrimaryIndexProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NotForReplicationColumnConstraint">sqlglot.expressions.NotForReplicationColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnCommitProperty">sqlglot.expressions.OnCommitProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnProperty">sqlglot.expressions.OnProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnUpdateColumnConstraint">sqlglot.expressions.OnUpdateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OutputModelProperty">sqlglot.expressions.OutputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#PathColumnConstraint">sqlglot.expressions.PathColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#RemoteWithConnectionModelProperty">sqlglot.expressions.RemoteWithConnectionModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ReturnsProperty">sqlglot.expressions.ReturnsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SampleProperty">sqlglot.expressions.SampleProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetConfigProperty">sqlglot.expressions.SetConfigProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetProperty">sqlglot.expressions.SetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SettingsProperty">sqlglot.expressions.SettingsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SharingProperty">sqlglot.expressions.SharingProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlReadWriteProperty">sqlglot.expressions.SqlReadWriteProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlSecurityProperty">sqlglot.expressions.SqlSecurityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#StabilityProperty">sqlglot.expressions.StabilityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TemporaryProperty">sqlglot.expressions.TemporaryProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TitleColumnConstraint">sqlglot.expressions.TitleColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToTableProperty">sqlglot.expressions.ToTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransformModelProperty">sqlglot.expressions.TransformModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransientProperty">sqlglot.expressions.TransientProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UppercaseColumnConstraint">sqlglot.expressions.UppercaseColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UnloggedProperty">sqlglot.expressions.UnloggedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VarMap">sqlglot.expressions.VarMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ViewAttributeProperty">sqlglot.expressions.ViewAttributeProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VolatileProperty">sqlglot.expressions.VolatileProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithJournalTableProperty">sqlglot.expressions.WithJournalTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithOperator">sqlglot.expressions.WithOperator</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Max">sqlglot.expressions.Max</a>'>: <function max_or_greatest>, <class '<a href="../expressions.html#Min">sqlglot.expressions.Min</a>'>: <function min_or_least>, <class '<a href="../expressions.html#Pow">sqlglot.expressions.Pow</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Select">sqlglot.expressions.Select</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#StrToDate">sqlglot.expressions.StrToDate</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>, <class '<a href="../expressions.html#ToChar">sqlglot.expressions.ToChar</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>, <class '<a href="../expressions.html#ToNumber">sqlglot.expressions.ToNumber</a>'>: <function to_number_with_nls_param>, <class '<a href="../expressions.html#Use">sqlglot.expressions.Use</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>}</span> + <label class="view-value-button pdoc-button" for="Teradata.Generator.TRANSFORMS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathFilter">sqlglot.expressions.JSONPathFilter</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathRecursive">sqlglot.expressions.JSONPathRecursive</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathScript">sqlglot.expressions.JSONPathScript</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathSelector">sqlglot.expressions.JSONPathSelector</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathSlice">sqlglot.expressions.JSONPathSlice</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathUnion">sqlglot.expressions.JSONPathUnion</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathWildcard">sqlglot.expressions.JSONPathWildcard</a>'>: <function <lambda>>, <class '<a href="../expressions.html#AutoRefreshProperty">sqlglot.expressions.AutoRefreshProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#BackupProperty">sqlglot.expressions.BackupProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CaseSpecificColumnConstraint">sqlglot.expressions.CaseSpecificColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetColumnConstraint">sqlglot.expressions.CharacterSetColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetProperty">sqlglot.expressions.CharacterSetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ClusteredColumnConstraint">sqlglot.expressions.ClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CollateColumnConstraint">sqlglot.expressions.CollateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CommentColumnConstraint">sqlglot.expressions.CommentColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CopyGrantsProperty">sqlglot.expressions.CopyGrantsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DateFormatColumnConstraint">sqlglot.expressions.DateFormatColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DefaultColumnConstraint">sqlglot.expressions.DefaultColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EncodeColumnConstraint">sqlglot.expressions.EncodeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EphemeralColumnConstraint">sqlglot.expressions.EphemeralColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExcludeColumnConstraint">sqlglot.expressions.ExcludeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExecuteAsProperty">sqlglot.expressions.ExecuteAsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExternalProperty">sqlglot.expressions.ExternalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#GlobalProperty">sqlglot.expressions.GlobalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#HeapProperty">sqlglot.expressions.HeapProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IcebergProperty">sqlglot.expressions.IcebergProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InheritsProperty">sqlglot.expressions.InheritsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InlineLengthColumnConstraint">sqlglot.expressions.InlineLengthColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InputModelProperty">sqlglot.expressions.InputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IntervalSpan">sqlglot.expressions.IntervalSpan</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#JSONExtract">sqlglot.expressions.JSONExtract</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#JSONExtractScalar">sqlglot.expressions.JSONExtractScalar</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LanguageProperty">sqlglot.expressions.LanguageProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LocationProperty">sqlglot.expressions.LocationProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LogProperty">sqlglot.expressions.LogProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#MaterializedProperty">sqlglot.expressions.MaterializedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NonClusteredColumnConstraint">sqlglot.expressions.NonClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NoPrimaryIndexProperty">sqlglot.expressions.NoPrimaryIndexProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NotForReplicationColumnConstraint">sqlglot.expressions.NotForReplicationColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnCommitProperty">sqlglot.expressions.OnCommitProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnProperty">sqlglot.expressions.OnProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnUpdateColumnConstraint">sqlglot.expressions.OnUpdateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OutputModelProperty">sqlglot.expressions.OutputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#PathColumnConstraint">sqlglot.expressions.PathColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#RemoteWithConnectionModelProperty">sqlglot.expressions.RemoteWithConnectionModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ReturnsProperty">sqlglot.expressions.ReturnsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SampleProperty">sqlglot.expressions.SampleProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetConfigProperty">sqlglot.expressions.SetConfigProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetProperty">sqlglot.expressions.SetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SettingsProperty">sqlglot.expressions.SettingsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SharingProperty">sqlglot.expressions.SharingProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlReadWriteProperty">sqlglot.expressions.SqlReadWriteProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlSecurityProperty">sqlglot.expressions.SqlSecurityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#StabilityProperty">sqlglot.expressions.StabilityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TemporaryProperty">sqlglot.expressions.TemporaryProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TitleColumnConstraint">sqlglot.expressions.TitleColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToTableProperty">sqlglot.expressions.ToTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransformModelProperty">sqlglot.expressions.TransformModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransientProperty">sqlglot.expressions.TransientProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UppercaseColumnConstraint">sqlglot.expressions.UppercaseColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UnloggedProperty">sqlglot.expressions.UnloggedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VarMap">sqlglot.expressions.VarMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ViewAttributeProperty">sqlglot.expressions.ViewAttributeProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VolatileProperty">sqlglot.expressions.VolatileProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithJournalTableProperty">sqlglot.expressions.WithJournalTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithOperator">sqlglot.expressions.WithOperator</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Max">sqlglot.expressions.Max</a>'>: <function max_or_greatest>, <class '<a href="../expressions.html#Min">sqlglot.expressions.Min</a>'>: <function min_or_least>, <class '<a href="../expressions.html#Pow">sqlglot.expressions.Pow</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Select">sqlglot.expressions.Select</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#StrToDate">sqlglot.expressions.StrToDate</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>, <class '<a href="../expressions.html#ToChar">sqlglot.expressions.ToChar</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>, <class '<a href="../expressions.html#ToNumber">sqlglot.expressions.ToNumber</a>'>: <function to_number_with_nls_param>, <class '<a href="../expressions.html#Use">sqlglot.expressions.Use</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>, <class '<a href="../expressions.html#CurrentTimestamp">sqlglot.expressions.CurrentTimestamp</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DateAdd">sqlglot.expressions.DateAdd</a>'>: <function _date_add_sql.<locals>.func>, <class '<a href="../expressions.html#DateSub">sqlglot.expressions.DateSub</a>'>: <function _date_add_sql.<locals>.func>, <class '<a href="../expressions.html#Quarter">sqlglot.expressions.Quarter</a>'>: <function <a href="#Teradata.Generator">Teradata.Generator</a>.<lambda>>}</span> </div> @@ -1907,12 +2017,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-220"><a href="#Teradata.Generator.cast_sql-220"><span class="linenos">220</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-221"><a href="#Teradata.Generator.cast_sql-221"><span class="linenos">221</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-222"><a href="#Teradata.Generator.cast_sql-222"><span class="linenos">222</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-223"><a href="#Teradata.Generator.cast_sql-223"><span class="linenos">223</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-224"><a href="#Teradata.Generator.cast_sql-224"><span class="linenos">224</span></a> -</span><span id="Teradata.Generator.cast_sql-225"><a href="#Teradata.Generator.cast_sql-225"><span class="linenos">225</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-248"><a href="#Teradata.Generator.cast_sql-248"><span class="linenos">248</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-249"><a href="#Teradata.Generator.cast_sql-249"><span class="linenos">249</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-250"><a href="#Teradata.Generator.cast_sql-250"><span class="linenos">250</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-251"><a href="#Teradata.Generator.cast_sql-251"><span class="linenos">251</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-252"><a href="#Teradata.Generator.cast_sql-252"><span class="linenos">252</span></a> +</span><span id="Teradata.Generator.cast_sql-253"><a href="#Teradata.Generator.cast_sql-253"><span class="linenos">253</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> @@ -1930,8 +2040,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-227"><a href="#Teradata.Generator.trycast_sql-227"><span class="linenos">227</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-228"><a href="#Teradata.Generator.trycast_sql-228"><span class="linenos">228</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-255"><a href="#Teradata.Generator.trycast_sql-255"><span class="linenos">255</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-256"><a href="#Teradata.Generator.trycast_sql-256"><span class="linenos">256</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> @@ -1949,13 +2059,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-230"><a href="#Teradata.Generator.tablesample_sql-230"><span class="linenos">230</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Teradata.Generator.tablesample_sql-231"><a href="#Teradata.Generator.tablesample_sql-231"><span class="linenos">231</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Teradata.Generator.tablesample_sql-232"><a href="#Teradata.Generator.tablesample_sql-232"><span class="linenos">232</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-233"><a href="#Teradata.Generator.tablesample_sql-233"><span class="linenos">233</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-234"><a href="#Teradata.Generator.tablesample_sql-234"><span class="linenos">234</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-235"><a href="#Teradata.Generator.tablesample_sql-235"><span class="linenos">235</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-236"><a href="#Teradata.Generator.tablesample_sql-236"><span class="linenos">236</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-258"><a href="#Teradata.Generator.tablesample_sql-258"><span class="linenos">258</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="Teradata.Generator.tablesample_sql-259"><a href="#Teradata.Generator.tablesample_sql-259"><span class="linenos">259</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Teradata.Generator.tablesample_sql-260"><a href="#Teradata.Generator.tablesample_sql-260"><span class="linenos">260</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-261"><a href="#Teradata.Generator.tablesample_sql-261"><span class="linenos">261</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-262"><a href="#Teradata.Generator.tablesample_sql-262"><span class="linenos">262</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-263"><a href="#Teradata.Generator.tablesample_sql-263"><span class="linenos">263</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-264"><a href="#Teradata.Generator.tablesample_sql-264"><span class="linenos">264</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> @@ -1973,8 +2083,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-238"><a href="#Teradata.Generator.partitionedbyproperty_sql-238"><span class="linenos">238</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-239"><a href="#Teradata.Generator.partitionedbyproperty_sql-239"><span class="linenos">239</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-266"><a href="#Teradata.Generator.partitionedbyproperty_sql-266"><span class="linenos">266</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-267"><a href="#Teradata.Generator.partitionedbyproperty_sql-267"><span class="linenos">267</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> @@ -1992,13 +2102,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-243"><a href="#Teradata.Generator.update_sql-243"><span class="linenos">243</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-244"><a href="#Teradata.Generator.update_sql-244"><span class="linenos">244</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-245"><a href="#Teradata.Generator.update_sql-245"><span class="linenos">245</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-246"><a href="#Teradata.Generator.update_sql-246"><span class="linenos">246</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-247"><a href="#Teradata.Generator.update_sql-247"><span class="linenos">247</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-248"><a href="#Teradata.Generator.update_sql-248"><span class="linenos">248</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-249"><a href="#Teradata.Generator.update_sql-249"><span class="linenos">249</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-271"><a href="#Teradata.Generator.update_sql-271"><span class="linenos">271</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-272"><a href="#Teradata.Generator.update_sql-272"><span class="linenos">272</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-273"><a href="#Teradata.Generator.update_sql-273"><span class="linenos">273</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-274"><a href="#Teradata.Generator.update_sql-274"><span class="linenos">274</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-275"><a href="#Teradata.Generator.update_sql-275"><span class="linenos">275</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-276"><a href="#Teradata.Generator.update_sql-276"><span class="linenos">276</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-277"><a href="#Teradata.Generator.update_sql-277"><span class="linenos">277</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> @@ -2016,8 +2126,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-251"><a href="#Teradata.Generator.mod_sql-251"><span class="linenos">251</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-252"><a href="#Teradata.Generator.mod_sql-252"><span class="linenos">252</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-279"><a href="#Teradata.Generator.mod_sql-279"><span class="linenos">279</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-280"><a href="#Teradata.Generator.mod_sql-280"><span class="linenos">280</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> @@ -2035,10 +2145,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-254"><a href="#Teradata.Generator.datatype_sql-254"><span class="linenos">254</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-255"><a href="#Teradata.Generator.datatype_sql-255"><span class="linenos">255</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-256"><a href="#Teradata.Generator.datatype_sql-256"><span class="linenos">256</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-257"><a href="#Teradata.Generator.datatype_sql-257"><span class="linenos">257</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-282"><a href="#Teradata.Generator.datatype_sql-282"><span class="linenos">282</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-283"><a href="#Teradata.Generator.datatype_sql-283"><span class="linenos">283</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-284"><a href="#Teradata.Generator.datatype_sql-284"><span class="linenos">284</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-285"><a href="#Teradata.Generator.datatype_sql-285"><span class="linenos">285</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> @@ -2056,13 +2166,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-259"><a href="#Teradata.Generator.rangen_sql-259"><span class="linenos">259</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-260"><a href="#Teradata.Generator.rangen_sql-260"><span class="linenos">260</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-261"><a href="#Teradata.Generator.rangen_sql-261"><span class="linenos">261</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-262"><a href="#Teradata.Generator.rangen_sql-262"><span class="linenos">262</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-263"><a href="#Teradata.Generator.rangen_sql-263"><span class="linenos">263</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-264"><a href="#Teradata.Generator.rangen_sql-264"><span class="linenos">264</span></a> -</span><span id="Teradata.Generator.rangen_sql-265"><a href="#Teradata.Generator.rangen_sql-265"><span class="linenos">265</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-287"><a href="#Teradata.Generator.rangen_sql-287"><span class="linenos">287</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-288"><a href="#Teradata.Generator.rangen_sql-288"><span class="linenos">288</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-289"><a href="#Teradata.Generator.rangen_sql-289"><span class="linenos">289</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-290"><a href="#Teradata.Generator.rangen_sql-290"><span class="linenos">290</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-291"><a href="#Teradata.Generator.rangen_sql-291"><span class="linenos">291</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-292"><a href="#Teradata.Generator.rangen_sql-292"><span class="linenos">292</span></a> +</span><span id="Teradata.Generator.rangen_sql-293"><a href="#Teradata.Generator.rangen_sql-293"><span class="linenos">293</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> @@ -2080,19 +2190,73 @@ 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-267"><a href="#Teradata.Generator.createable_sql-267"><span class="linenos">267</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-268"><a href="#Teradata.Generator.createable_sql-268"><span class="linenos">268</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-269"><a href="#Teradata.Generator.createable_sql-269"><span class="linenos">269</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-270"><a href="#Teradata.Generator.createable_sql-270"><span class="linenos">270</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-271"><a href="#Teradata.Generator.createable_sql-271"><span class="linenos">271</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-272"><a href="#Teradata.Generator.createable_sql-272"><span class="linenos">272</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-273"><a href="#Teradata.Generator.createable_sql-273"><span class="linenos">273</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-274"><a href="#Teradata.Generator.createable_sql-274"><span class="linenos">274</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-275"><a href="#Teradata.Generator.createable_sql-275"><span class="linenos">275</span></a> <span class="p">)</span> -</span><span id="Teradata.Generator.createable_sql-276"><a href="#Teradata.Generator.createable_sql-276"><span class="linenos">276</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-277"><a href="#Teradata.Generator.createable_sql-277"><span class="linenos">277</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-278"><a href="#Teradata.Generator.createable_sql-278"><span class="linenos">278</span></a> -</span><span id="Teradata.Generator.createable_sql-279"><a href="#Teradata.Generator.createable_sql-279"><span class="linenos">279</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-295"><a href="#Teradata.Generator.createable_sql-295"><span class="linenos">295</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-296"><a href="#Teradata.Generator.createable_sql-296"><span class="linenos">296</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-297"><a href="#Teradata.Generator.createable_sql-297"><span class="linenos">297</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-298"><a href="#Teradata.Generator.createable_sql-298"><span class="linenos">298</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-299"><a href="#Teradata.Generator.createable_sql-299"><span class="linenos">299</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-300"><a href="#Teradata.Generator.createable_sql-300"><span class="linenos">300</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-301"><a href="#Teradata.Generator.createable_sql-301"><span class="linenos">301</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-302"><a href="#Teradata.Generator.createable_sql-302"><span class="linenos">302</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-303"><a href="#Teradata.Generator.createable_sql-303"><span class="linenos">303</span></a> <span class="p">)</span> +</span><span id="Teradata.Generator.createable_sql-304"><a href="#Teradata.Generator.createable_sql-304"><span class="linenos">304</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-305"><a href="#Teradata.Generator.createable_sql-305"><span class="linenos">305</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-306"><a href="#Teradata.Generator.createable_sql-306"><span class="linenos">306</span></a> +</span><span id="Teradata.Generator.createable_sql-307"><a href="#Teradata.Generator.createable_sql-307"><span class="linenos">307</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> + + + + + </div> + <div id="Teradata.Generator.extract_sql" class="classattr"> + <input id="Teradata.Generator.extract_sql-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + + <span class="def">def</span> + <span class="name">extract_sql</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">expression</span><span class="p">:</span> <span class="n"><a href="../expressions.html#Extract">sqlglot.expressions.Extract</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> + + <label class="view-source-button" for="Teradata.Generator.extract_sql-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Teradata.Generator.extract_sql"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.extract_sql-309"><a href="#Teradata.Generator.extract_sql-309"><span class="linenos">309</span></a> <span class="k">def</span> <span class="nf">extract_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">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.extract_sql-310"><a href="#Teradata.Generator.extract_sql-310"><span class="linenos">310</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.extract_sql-311"><a href="#Teradata.Generator.extract_sql-311"><span class="linenos">311</span></a> <span class="k">if</span> <span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"QUARTER"</span><span class="p">:</span> +</span><span id="Teradata.Generator.extract_sql-312"><a href="#Teradata.Generator.extract_sql-312"><span class="linenos">312</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">extract_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Teradata.Generator.extract_sql-313"><a href="#Teradata.Generator.extract_sql-313"><span class="linenos">313</span></a> +</span><span id="Teradata.Generator.extract_sql-314"><a href="#Teradata.Generator.extract_sql-314"><span class="linenos">314</span></a> <span class="n">to_char</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"to_char"</span><span class="p">,</span> <span class="n">expression</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"Q"</span><span class="p">))</span> +</span><span id="Teradata.Generator.extract_sql-315"><a href="#Teradata.Generator.extract_sql-315"><span class="linenos">315</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">to_char</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">))</span> +</span></pre></div> + + + + + </div> + <div id="Teradata.Generator.interval_sql" class="classattr"> + <input id="Teradata.Generator.interval_sql-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + + <span class="def">def</span> + <span class="name">interval_sql</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">expression</span><span class="p">:</span> <span class="n"><a href="../expressions.html#Interval">sqlglot.expressions.Interval</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> + + <label class="view-source-button" for="Teradata.Generator.interval_sql-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Teradata.Generator.interval_sql"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.interval_sql-317"><a href="#Teradata.Generator.interval_sql-317"><span class="linenos">317</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Teradata.Generator.interval_sql-318"><a href="#Teradata.Generator.interval_sql-318"><span class="linenos">318</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Teradata.Generator.interval_sql-319"><a href="#Teradata.Generator.interval_sql-319"><span class="linenos">319</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Teradata.Generator.interval_sql-320"><a href="#Teradata.Generator.interval_sql-320"><span class="linenos">320</span></a> +</span><span id="Teradata.Generator.interval_sql-321"><a href="#Teradata.Generator.interval_sql-321"><span class="linenos">321</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"WEEK"</span><span class="p">):</span> +</span><span id="Teradata.Generator.interval_sql-322"><a href="#Teradata.Generator.interval_sql-322"><span class="linenos">322</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="Teradata.Generator.interval_sql-323"><a href="#Teradata.Generator.interval_sql-323"><span class="linenos">323</span></a> <span class="k">elif</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"QUARTER"</span><span class="p">):</span> +</span><span id="Teradata.Generator.interval_sql-324"><a href="#Teradata.Generator.interval_sql-324"><span class="linenos">324</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="Teradata.Generator.interval_sql-325"><a href="#Teradata.Generator.interval_sql-325"><span class="linenos">325</span></a> +</span><span id="Teradata.Generator.interval_sql-326"><a href="#Teradata.Generator.interval_sql-326"><span class="linenos">326</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="Teradata.Generator.interval_sql-327"><a href="#Teradata.Generator.interval_sql-327"><span class="linenos">327</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Teradata.Generator.interval_sql-328"><a href="#Teradata.Generator.interval_sql-328"><span class="linenos">328</span></a> +</span><span id="Teradata.Generator.interval_sql-329"><a href="#Teradata.Generator.interval_sql-329"><span class="linenos">329</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2180,6 +2344,7 @@ Default: True</li> <dd id="Teradata.Generator.JSON_PATH_SINGLE_QUOTE_ESCAPE" class="variable"><a href="../generator.html#Generator.JSON_PATH_SINGLE_QUOTE_ESCAPE">JSON_PATH_SINGLE_QUOTE_ESCAPE</a></dd> <dd id="Teradata.Generator.SUPPORTED_JSON_PATH_PARTS" class="variable"><a href="../generator.html#Generator.SUPPORTED_JSON_PATH_PARTS">SUPPORTED_JSON_PATH_PARTS</a></dd> <dd id="Teradata.Generator.SUPPORTS_TO_NUMBER" class="variable"><a href="../generator.html#Generator.SUPPORTS_TO_NUMBER">SUPPORTS_TO_NUMBER</a></dd> + <dd id="Teradata.Generator.OUTER_UNION_MODIFIERS" class="variable"><a href="../generator.html#Generator.OUTER_UNION_MODIFIERS">OUTER_UNION_MODIFIERS</a></dd> <dd id="Teradata.Generator.STAR_MAPPING" class="variable"><a href="../generator.html#Generator.STAR_MAPPING">STAR_MAPPING</a></dd> <dd id="Teradata.Generator.TIME_PART_SINGULARS" class="variable"><a href="../generator.html#Generator.TIME_PART_SINGULARS">TIME_PART_SINGULARS</a></dd> <dd id="Teradata.Generator.TOKEN_MAPPING" class="variable"><a href="../generator.html#Generator.TOKEN_MAPPING">TOKEN_MAPPING</a></dd> @@ -2331,6 +2496,7 @@ Default: True</li> <dd id="Teradata.Generator.distribute_sql" class="function"><a href="../generator.html#Generator.distribute_sql">distribute_sql</a></dd> <dd id="Teradata.Generator.sort_sql" class="function"><a href="../generator.html#Generator.sort_sql">sort_sql</a></dd> <dd id="Teradata.Generator.ordered_sql" class="function"><a href="../generator.html#Generator.ordered_sql">ordered_sql</a></dd> + <dd id="Teradata.Generator.matchrecognizemeasure_sql" class="function"><a href="../generator.html#Generator.matchrecognizemeasure_sql">matchrecognizemeasure_sql</a></dd> <dd id="Teradata.Generator.matchrecognize_sql" class="function"><a href="../generator.html#Generator.matchrecognize_sql">matchrecognize_sql</a></dd> <dd id="Teradata.Generator.query_modifiers" class="function"><a href="../generator.html#Generator.query_modifiers">query_modifiers</a></dd> <dd id="Teradata.Generator.queryoption_sql" class="function"><a href="../generator.html#Generator.queryoption_sql">queryoption_sql</a></dd> @@ -2356,6 +2522,7 @@ Default: True</li> <dd id="Teradata.Generator.windowspec_sql" class="function"><a href="../generator.html#Generator.windowspec_sql">windowspec_sql</a></dd> <dd id="Teradata.Generator.withingroup_sql" class="function"><a href="../generator.html#Generator.withingroup_sql">withingroup_sql</a></dd> <dd id="Teradata.Generator.between_sql" class="function"><a href="../generator.html#Generator.between_sql">between_sql</a></dd> + <dd id="Teradata.Generator.bracket_offset_expressions" class="function"><a href="../generator.html#Generator.bracket_offset_expressions">bracket_offset_expressions</a></dd> <dd id="Teradata.Generator.bracket_sql" class="function"><a href="../generator.html#Generator.bracket_sql">bracket_sql</a></dd> <dd id="Teradata.Generator.all_sql" class="function"><a href="../generator.html#Generator.all_sql">all_sql</a></dd> <dd id="Teradata.Generator.any_sql" class="function"><a href="../generator.html#Generator.any_sql">any_sql</a></dd> @@ -2363,7 +2530,6 @@ Default: True</li> <dd id="Teradata.Generator.case_sql" class="function"><a href="../generator.html#Generator.case_sql">case_sql</a></dd> <dd id="Teradata.Generator.constraint_sql" class="function"><a href="../generator.html#Generator.constraint_sql">constraint_sql</a></dd> <dd id="Teradata.Generator.nextvaluefor_sql" class="function"><a href="../generator.html#Generator.nextvaluefor_sql">nextvaluefor_sql</a></dd> - <dd id="Teradata.Generator.extract_sql" class="function"><a href="../generator.html#Generator.extract_sql">extract_sql</a></dd> <dd id="Teradata.Generator.trim_sql" class="function"><a href="../generator.html#Generator.trim_sql">trim_sql</a></dd> <dd id="Teradata.Generator.convert_concat_args" class="function"><a href="../generator.html#Generator.convert_concat_args">convert_concat_args</a></dd> <dd id="Teradata.Generator.concat_sql" class="function"><a href="../generator.html#Generator.concat_sql">concat_sql</a></dd> @@ -2388,7 +2554,6 @@ Default: True</li> <dd id="Teradata.Generator.openjson_sql" class="function"><a href="../generator.html#Generator.openjson_sql">openjson_sql</a></dd> <dd id="Teradata.Generator.in_sql" class="function"><a href="../generator.html#Generator.in_sql">in_sql</a></dd> <dd id="Teradata.Generator.in_unnest_op" class="function"><a href="../generator.html#Generator.in_unnest_op">in_unnest_op</a></dd> - <dd id="Teradata.Generator.interval_sql" class="function"><a href="../generator.html#Generator.interval_sql">interval_sql</a></dd> <dd id="Teradata.Generator.return_sql" class="function"><a href="../generator.html#Generator.return_sql">return_sql</a></dd> <dd id="Teradata.Generator.reference_sql" class="function"><a href="../generator.html#Generator.reference_sql">reference_sql</a></dd> <dd id="Teradata.Generator.anonymous_sql" class="function"><a href="../generator.html#Generator.anonymous_sql">anonymous_sql</a></dd> |