Edit on GitHub

sqlglot expressions - string, encoding, hashing, and regex functions.

  1"""sqlglot expressions - string, encoding, hashing, and regex functions."""
  2
  3from __future__ import annotations
  4
  5from sqlglot.expressions.core import Expression, Func, Binary, Predicate
  6
  7
  8# String basics
  9
 10
 11class Ascii(Expression, Func):
 12    pass
 13
 14
 15class BitLength(Expression, Func):
 16    pass
 17
 18
 19class ByteLength(Expression, Func):
 20    pass
 21
 22
 23class Chr(Expression, Func):
 24    arg_types = {"expressions": True, "charset": False}
 25    is_var_len_args = True
 26    _sql_names = ["CHR", "CHAR"]
 27
 28
 29class Concat(Expression, Func):
 30    arg_types = {"expressions": True, "safe": False, "coalesce": False}
 31    is_var_len_args = True
 32
 33
 34class ConcatWs(Concat):
 35    arg_types = {**Concat.arg_types, "flatten": False}
 36    _sql_names = ["CONCAT_WS"]
 37
 38
 39class Contains(Expression, Func):
 40    arg_types = {"this": True, "expression": True, "json_scope": False}
 41
 42
 43class Elt(Expression, Func):
 44    arg_types = {"this": True, "expressions": True}
 45    is_var_len_args = True
 46
 47
 48class EndsWith(Expression, Func):
 49    _sql_names = ["ENDS_WITH", "ENDSWITH"]
 50    arg_types = {"this": True, "expression": True}
 51
 52
 53class Format(Expression, Func):
 54    arg_types = {"this": True, "expressions": False}
 55    is_var_len_args = True
 56
 57
 58class Initcap(Expression, Func):
 59    arg_types = {"this": True, "expression": False}
 60
 61
 62class IsAscii(Expression, Func):
 63    pass
 64
 65
 66class Left(Expression, Func):
 67    arg_types = {"this": True, "expression": True, "negative_length_returns_empty": False}
 68
 69
 70class Length(Expression, Func):
 71    arg_types = {"this": True, "binary": False, "encoding": False}
 72    _sql_names = ["LENGTH", "LEN", "CHAR_LENGTH", "CHARACTER_LENGTH"]
 73
 74
 75class Levenshtein(Expression, Func):
 76    arg_types = {
 77        "this": True,
 78        "expression": False,
 79        "ins_cost": False,
 80        "del_cost": False,
 81        "sub_cost": False,
 82        "max_dist": False,
 83    }
 84
 85
 86class Lower(Expression, Func):
 87    _sql_names = ["LOWER", "LCASE"]
 88
 89
 90class MatchAgainst(Expression, Func):
 91    arg_types = {"this": True, "expressions": True, "modifier": False}
 92
 93
 94class Normalize(Expression, Func):
 95    arg_types = {"this": True, "form": False, "is_casefold": False}
 96
 97
 98class NumberToStr(Expression, Func):
 99    arg_types = {"this": True, "format": True, "culture": False}
100
101
102class Overlay(Expression, Func):
103    arg_types = {"this": True, "expression": True, "from_": True, "for_": False}
104
105
106class Pad(Expression, Func):
107    arg_types = {"this": True, "expression": True, "fill_pattern": False, "is_left": True}
108
109
110class Repeat(Expression, Func):
111    arg_types = {"this": True, "times": True}
112
113
114class Replace(Expression, Func):
115    arg_types = {"this": True, "expression": True, "replacement": False}
116
117
118class Reverse(Expression, Func):
119    pass
120
121
122class Right(Expression, Func):
123    arg_types = {"this": True, "expression": True, "negative_length_returns_empty": False}
124
125
126class RtrimmedLength(Expression, Func):
127    pass
128
129
130class Search(Expression, Func):
131    arg_types = {
132        "this": True,  # data_to_search / search_data
133        "expression": True,  # search_query / search_string
134        "json_scope": False,  # BigQuery: JSON_VALUES | JSON_KEYS | JSON_KEYS_AND_VALUES
135        "analyzer": False,  # Both: analyzer / ANALYZER
136        "analyzer_options": False,  # BigQuery: analyzer_options_values
137        "search_mode": False,  # Snowflake: OR | AND
138    }
139
140
141class SearchIp(Expression, Func):
142    arg_types = {"this": True, "expression": True}
143
144
145class Secret(Expression, Func):
146    arg_types = {"this": True, "expression": True}
147
148
149class Soundex(Expression, Func):
150    pass
151
152
153class SoundexP123(Expression, Func):
154    pass
155
156
157class Space(Expression, Func):
158    """
159    SPACE(n) → string consisting of n blank characters
160    """
161
162    pass
163
164
165class Split(Expression, Func):
166    arg_types = {
167        "this": True,
168        "expression": True,
169        "limit": False,
170        "null_returns_null": False,
171        "empty_delimiter_returns_whole": False,
172    }
173
174
175class SplitPart(Expression, Func):
176    arg_types = {
177        "this": True,
178        "delimiter": False,
179        "part_index": False,
180        "part_index_zero_as_one": False,  # usually part_index is 1-based, however Snowflake allows 0 and treats it as 1
181        "empty_delimiter_returns_whole": False,  # whether the whole input string should be returned if the delimiter string is empty (i.e. Snowflake)
182    }
183
184
185class Strtok(Expression, Func):
186    arg_types = {
187        "this": True,
188        "delimiter": False,
189        "part_index": False,
190    }
191
192
193class StartsWith(Expression, Func):
194    _sql_names = ["STARTS_WITH", "STARTSWITH"]
195    arg_types = {"this": True, "expression": True}
196
197
198class StrPosition(Expression, Func):
199    arg_types = {
200        "this": True,
201        "substr": True,
202        "position": False,
203        "occurrence": False,
204        "clamp_position": False,
205    }
206
207
208class StrToMap(Expression, Func):
209    arg_types = {
210        "this": True,
211        "pair_delim": False,
212        "key_value_delim": False,
213        "duplicate_resolution_callback": False,
214    }
215
216
217class String(Expression, Func):
218    arg_types = {"this": True, "zone": False}
219
220
221class Stuff(Expression, Func):
222    _sql_names = ["STUFF", "INSERT"]
223    arg_types = {"this": True, "start": True, "length": True, "expression": True}
224
225
226class Substring(Expression, Func):
227    _sql_names = ["SUBSTRING", "SUBSTR"]
228    arg_types = {"this": True, "start": False, "length": False, "zero_start": False}
229
230
231class SubstringIndex(Expression, Func):
232    """
233    SUBSTRING_INDEX(str, delim, count)
234
235    *count* > 0  → left slice before the *count*-th delimiter
236    *count* < 0  → right slice after the |count|-th delimiter
237    """
238
239    arg_types = {"this": True, "delimiter": True, "count": True}
240
241
242class Translate(Expression, Func):
243    arg_types = {"this": True, "from_": True, "to": True}
244
245
246class Trim(Expression, Func):
247    arg_types = {
248        "this": True,
249        "expression": False,
250        "position": False,
251        "collation": False,
252    }
253
254
255class Unicode(Expression, Func):
256    arg_types = {"this": True, "empty_is_zero": False}
257
258
259class Upper(Expression, Func):
260    _sql_names = ["UPPER", "UCASE"]
261
262
263class WeightString(Expression, Func):
264    arg_types = {"this": True, "to": False}
265
266
267# Encoding / base conversion
268
269
270class Base64DecodeBinary(Expression, Func):
271    arg_types = {"this": True, "alphabet": False}
272
273
274class Base64DecodeString(Expression, Func):
275    arg_types = {"this": True, "alphabet": False}
276
277
278class Base64Encode(Expression, Func):
279    arg_types = {"this": True, "max_line_length": False, "alphabet": False}
280
281
282class CodePointsToBytes(Expression, Func):
283    pass
284
285
286class CodePointsToString(Expression, Func):
287    pass
288
289
290class ConvertToCharset(Expression, Func):
291    arg_types = {"this": True, "dest": True, "source": False}
292
293
294class Decode(Expression, Func):
295    arg_types = {"this": True, "charset": True, "replace": False}
296
297
298class Encode(Expression, Func):
299    arg_types = {"this": True, "charset": True}
300
301
302class FromBase(Expression, Func):
303    arg_types = {"this": True, "expression": True}
304
305
306class FromBase32(Expression, Func):
307    pass
308
309
310class FromBase64(Expression, Func):
311    pass
312
313
314class Hex(Expression, Func):
315    arg_types = {"this": True, "case": False}
316
317
318class HexDecodeString(Expression, Func):
319    pass
320
321
322class LowerHex(Hex):
323    pass
324
325
326class SafeConvertBytesToString(Expression, Func):
327    pass
328
329
330class ToBase32(Expression, Func):
331    pass
332
333
334class ToBase64(Expression, Func):
335    pass
336
337
338class ToBinary(Expression, Func):
339    arg_types = {"this": True, "format": False, "safe": False}
340
341
342class ToChar(Expression, Func):
343    arg_types = {
344        "this": True,
345        "format": False,
346        "nlsparam": False,
347        "is_numeric": False,
348    }
349
350
351class ToCodePoints(Expression, Func):
352    pass
353
354
355class ToDecfloat(Expression, Func):
356    arg_types = {
357        "this": True,
358        "format": False,
359    }
360
361
362class ToDouble(Expression, Func):
363    arg_types = {
364        "this": True,
365        "format": False,
366        "safe": False,
367    }
368
369
370class ToFile(Expression, Func):
371    arg_types = {
372        "this": True,
373        "path": False,
374        "safe": False,
375    }
376
377
378class ToNumber(Expression, Func):
379    arg_types = {
380        "this": True,
381        "format": False,
382        "nlsparam": False,
383        "precision": False,
384        "scale": False,
385        "safe": False,
386        "safe_name": False,
387        "default": False,
388    }
389
390
391class TryBase64DecodeBinary(Expression, Func):
392    arg_types = {"this": True, "alphabet": False}
393
394
395class TryBase64DecodeString(Expression, Func):
396    arg_types = {"this": True, "alphabet": False}
397
398
399class TryHexDecodeBinary(Expression, Func):
400    pass
401
402
403class TryHexDecodeString(Expression, Func):
404    pass
405
406
407class TryToDecfloat(Expression, Func):
408    arg_types = {
409        "this": True,
410        "format": False,
411    }
412
413
414class Unhex(Expression, Func):
415    arg_types = {"this": True, "expression": False}
416
417
418# Regex
419
420
421class RegexpCount(Expression, Func):
422    arg_types = {
423        "this": True,
424        "expression": True,
425        "position": False,
426        "parameters": False,
427    }
428
429
430class RegexpExtract(Expression, Func):
431    arg_types = {
432        "this": True,
433        "expression": True,
434        "position": False,
435        "occurrence": False,
436        "parameters": False,
437        "group": False,
438        "null_if_pos_overflow": False,  # for transpilation target behavior
439    }
440
441
442class RegexpExtractAll(Expression, Func):
443    arg_types = {
444        "this": True,
445        "expression": True,
446        "group": False,
447        "parameters": False,
448        "position": False,
449        "occurrence": False,
450    }
451
452
453class RegexpFullMatch(Expression, Binary, Predicate, Func):
454    arg_types = {"this": True, "expression": True, "options": False}
455
456
457class RegexpILike(Expression, Binary, Predicate, Func):
458    arg_types = {"this": True, "expression": True, "flag": False}
459
460
461class RegexpInstr(Expression, Func):
462    arg_types = {
463        "this": True,
464        "expression": True,
465        "position": False,
466        "occurrence": False,
467        "option": False,
468        "parameters": False,
469        "group": False,
470    }
471
472
473class RegexpReplace(Expression, Func):
474    arg_types = {
475        "this": True,
476        "expression": True,
477        "replacement": False,
478        "position": False,
479        "occurrence": False,
480        "modifiers": False,
481        "single_replace": False,
482    }
483
484
485class RegexpSplit(Expression, Func):
486    # "mode" is Dremio-specific, appended after "limit" for from_arg_list compat
487    arg_types = {"this": True, "expression": True, "limit": False, "mode": False}
488
489
490class RegexpSubstr(Expression, Func):
491    arg_types = {
492        "this": True,
493        "expression": True,
494        "position": False,
495        "occurrence": False,
496        "parameters": False,
497        "group": False,
498    }
499
500
501# Hashing / cryptographic
502
503
504class Compress(Expression, Func):
505    arg_types = {"this": True, "method": False}
506
507
508class Decrypt(Expression, Func):
509    arg_types = {
510        "this": True,
511        "passphrase": True,
512        "aad": False,
513        "encryption_method": False,
514        "safe": False,
515    }
516
517
518class DecryptRaw(Expression, Func):
519    arg_types = {
520        "this": True,
521        "key": True,
522        "iv": True,
523        "aad": False,
524        "encryption_method": False,
525        "aead": False,
526        "safe": False,
527    }
528
529
530class DecompressBinary(Expression, Func):
531    arg_types = {"this": True, "method": True}
532
533
534class DecompressString(Expression, Func):
535    arg_types = {"this": True, "method": True}
536
537
538class Encrypt(Expression, Func):
539    arg_types = {"this": True, "passphrase": True, "aad": False, "encryption_method": False}
540
541
542class EncryptRaw(Expression, Func):
543    arg_types = {"this": True, "key": True, "iv": True, "aad": False, "encryption_method": False}
544
545
546class CityHash64(Expression, Func):
547    arg_types = {"expressions": False}
548    is_var_len_args = True
549
550
551class FarmFingerprint(Expression, Func):
552    arg_types = {"expressions": True}
553    is_var_len_args = True
554    _sql_names = ["FARM_FINGERPRINT", "FARMFINGERPRINT64"]
555
556
557class MD5(Expression, Func):
558    _sql_names = ["MD5"]
559
560
561class MD5Digest(Expression, Func):
562    arg_types = {"this": True, "expressions": False}
563    is_var_len_args = True
564    _sql_names = ["MD5_DIGEST"]
565
566
567class MD5NumberLower64(Expression, Func):
568    pass
569
570
571class MD5NumberUpper64(Expression, Func):
572    pass
573
574
575class SHA(Expression, Func):
576    _sql_names = ["SHA", "SHA1"]
577
578
579class SHA1Digest(Expression, Func):
580    pass
581
582
583class SHA2(Expression, Func):
584    _sql_names = ["SHA2"]
585    arg_types = {"this": True, "length": False}
586
587
588class SHA2Digest(Expression, Func):
589    arg_types = {"this": True, "length": False}
590
591
592class StandardHash(Expression, Func):
593    arg_types = {"this": True, "expression": False}
594
595
596# Parse
597
598
599class ParseBignumeric(Expression, Func):
600    pass
601
602
603class ParseNumeric(Expression, Func):
604    pass
605
606
607class ParseUrl(Expression, Func):
608    arg_types = {"this": True, "part_to_extract": False, "key": False, "permissive": False}
12class Ascii(Expression, Func):
13    pass
key: ClassVar[str] = 'ascii'
required_args: 't.ClassVar[set[str]]' = {'this'}
16class BitLength(Expression, Func):
17    pass
key: ClassVar[str] = 'bitlength'
required_args: 't.ClassVar[set[str]]' = {'this'}
20class ByteLength(Expression, Func):
21    pass
key: ClassVar[str] = 'bytelength'
required_args: 't.ClassVar[set[str]]' = {'this'}
24class Chr(Expression, Func):
25    arg_types = {"expressions": True, "charset": False}
26    is_var_len_args = True
27    _sql_names = ["CHR", "CHAR"]
arg_types = {'expressions': True, 'charset': False}
is_var_len_args = True
key: ClassVar[str] = 'chr'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
30class Concat(Expression, Func):
31    arg_types = {"expressions": True, "safe": False, "coalesce": False}
32    is_var_len_args = True
arg_types = {'expressions': True, 'safe': False, 'coalesce': False}
is_var_len_args = True
key: ClassVar[str] = 'concat'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
class ConcatWs(Concat):
35class ConcatWs(Concat):
36    arg_types = {**Concat.arg_types, "flatten": False}
37    _sql_names = ["CONCAT_WS"]
arg_types = {'expressions': True, 'safe': False, 'coalesce': False, 'flatten': False}
key: ClassVar[str] = 'concatws'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
40class Contains(Expression, Func):
41    arg_types = {"this": True, "expression": True, "json_scope": False}
arg_types = {'this': True, 'expression': True, 'json_scope': False}
key: ClassVar[str] = 'contains'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
44class Elt(Expression, Func):
45    arg_types = {"this": True, "expressions": True}
46    is_var_len_args = True
arg_types = {'this': True, 'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'elt'
required_args: 't.ClassVar[set[str]]' = {'expressions', 'this'}
49class EndsWith(Expression, Func):
50    _sql_names = ["ENDS_WITH", "ENDSWITH"]
51    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'endswith'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
54class Format(Expression, Func):
55    arg_types = {"this": True, "expressions": False}
56    is_var_len_args = True
arg_types = {'this': True, 'expressions': False}
is_var_len_args = True
key: ClassVar[str] = 'format'
required_args: 't.ClassVar[set[str]]' = {'this'}
59class Initcap(Expression, Func):
60    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'initcap'
required_args: 't.ClassVar[set[str]]' = {'this'}
63class IsAscii(Expression, Func):
64    pass
key: ClassVar[str] = 'isascii'
required_args: 't.ClassVar[set[str]]' = {'this'}
67class Left(Expression, Func):
68    arg_types = {"this": True, "expression": True, "negative_length_returns_empty": False}
arg_types = {'this': True, 'expression': True, 'negative_length_returns_empty': False}
key: ClassVar[str] = 'left'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
71class Length(Expression, Func):
72    arg_types = {"this": True, "binary": False, "encoding": False}
73    _sql_names = ["LENGTH", "LEN", "CHAR_LENGTH", "CHARACTER_LENGTH"]
arg_types = {'this': True, 'binary': False, 'encoding': False}
key: ClassVar[str] = 'length'
required_args: 't.ClassVar[set[str]]' = {'this'}
76class Levenshtein(Expression, Func):
77    arg_types = {
78        "this": True,
79        "expression": False,
80        "ins_cost": False,
81        "del_cost": False,
82        "sub_cost": False,
83        "max_dist": False,
84    }
arg_types = {'this': True, 'expression': False, 'ins_cost': False, 'del_cost': False, 'sub_cost': False, 'max_dist': False}
key: ClassVar[str] = 'levenshtein'
required_args: 't.ClassVar[set[str]]' = {'this'}
87class Lower(Expression, Func):
88    _sql_names = ["LOWER", "LCASE"]
key: ClassVar[str] = 'lower'
required_args: 't.ClassVar[set[str]]' = {'this'}
91class MatchAgainst(Expression, Func):
92    arg_types = {"this": True, "expressions": True, "modifier": False}
arg_types = {'this': True, 'expressions': True, 'modifier': False}
key: ClassVar[str] = 'matchagainst'
required_args: 't.ClassVar[set[str]]' = {'expressions', 'this'}
95class Normalize(Expression, Func):
96    arg_types = {"this": True, "form": False, "is_casefold": False}
arg_types = {'this': True, 'form': False, 'is_casefold': False}
key: ClassVar[str] = 'normalize'
required_args: 't.ClassVar[set[str]]' = {'this'}
 99class NumberToStr(Expression, Func):
100    arg_types = {"this": True, "format": True, "culture": False}
arg_types = {'this': True, 'format': True, 'culture': False}
key: ClassVar[str] = 'numbertostr'
required_args: 't.ClassVar[set[str]]' = {'format', 'this'}
103class Overlay(Expression, Func):
104    arg_types = {"this": True, "expression": True, "from_": True, "for_": False}
arg_types = {'this': True, 'expression': True, 'from_': True, 'for_': False}
key: ClassVar[str] = 'overlay'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this', 'from_'}
107class Pad(Expression, Func):
108    arg_types = {"this": True, "expression": True, "fill_pattern": False, "is_left": True}
arg_types = {'this': True, 'expression': True, 'fill_pattern': False, 'is_left': True}
key: ClassVar[str] = 'pad'
required_args: 't.ClassVar[set[str]]' = {'expression', 'is_left', 'this'}
111class Repeat(Expression, Func):
112    arg_types = {"this": True, "times": True}
arg_types = {'this': True, 'times': True}
key: ClassVar[str] = 'repeat'
required_args: 't.ClassVar[set[str]]' = {'times', 'this'}
115class Replace(Expression, Func):
116    arg_types = {"this": True, "expression": True, "replacement": False}
arg_types = {'this': True, 'expression': True, 'replacement': False}
key: ClassVar[str] = 'replace'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
119class Reverse(Expression, Func):
120    pass
key: ClassVar[str] = 'reverse'
required_args: 't.ClassVar[set[str]]' = {'this'}
127class RtrimmedLength(Expression, Func):
128    pass
key: ClassVar[str] = 'rtrimmedlength'
required_args: 't.ClassVar[set[str]]' = {'this'}
142class SearchIp(Expression, Func):
143    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'searchip'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
146class Secret(Expression, Func):
147    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'secret'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
150class Soundex(Expression, Func):
151    pass
key: ClassVar[str] = 'soundex'
required_args: 't.ClassVar[set[str]]' = {'this'}
154class SoundexP123(Expression, Func):
155    pass
key: ClassVar[str] = 'soundexp123'
required_args: 't.ClassVar[set[str]]' = {'this'}
158class Space(Expression, Func):
159    """
160    SPACE(n) → string consisting of n blank characters
161    """
162
163    pass

SPACE(n) → string consisting of n blank characters

key: ClassVar[str] = 'space'
required_args: 't.ClassVar[set[str]]' = {'this'}
166class Split(Expression, Func):
167    arg_types = {
168        "this": True,
169        "expression": True,
170        "limit": False,
171        "null_returns_null": False,
172        "empty_delimiter_returns_whole": False,
173    }
arg_types = {'this': True, 'expression': True, 'limit': False, 'null_returns_null': False, 'empty_delimiter_returns_whole': False}
key: ClassVar[str] = 'split'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
176class SplitPart(Expression, Func):
177    arg_types = {
178        "this": True,
179        "delimiter": False,
180        "part_index": False,
181        "part_index_zero_as_one": False,  # usually part_index is 1-based, however Snowflake allows 0 and treats it as 1
182        "empty_delimiter_returns_whole": False,  # whether the whole input string should be returned if the delimiter string is empty (i.e. Snowflake)
183    }
arg_types = {'this': True, 'delimiter': False, 'part_index': False, 'part_index_zero_as_one': False, 'empty_delimiter_returns_whole': False}
key: ClassVar[str] = 'splitpart'
required_args: 't.ClassVar[set[str]]' = {'this'}
186class Strtok(Expression, Func):
187    arg_types = {
188        "this": True,
189        "delimiter": False,
190        "part_index": False,
191    }
arg_types = {'this': True, 'delimiter': False, 'part_index': False}
key: ClassVar[str] = 'strtok'
required_args: 't.ClassVar[set[str]]' = {'this'}
194class StartsWith(Expression, Func):
195    _sql_names = ["STARTS_WITH", "STARTSWITH"]
196    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'startswith'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
199class StrPosition(Expression, Func):
200    arg_types = {
201        "this": True,
202        "substr": True,
203        "position": False,
204        "occurrence": False,
205        "clamp_position": False,
206    }
arg_types = {'this': True, 'substr': True, 'position': False, 'occurrence': False, 'clamp_position': False}
key: ClassVar[str] = 'strposition'
required_args: 't.ClassVar[set[str]]' = {'this', 'substr'}
209class StrToMap(Expression, Func):
210    arg_types = {
211        "this": True,
212        "pair_delim": False,
213        "key_value_delim": False,
214        "duplicate_resolution_callback": False,
215    }
arg_types = {'this': True, 'pair_delim': False, 'key_value_delim': False, 'duplicate_resolution_callback': False}
key: ClassVar[str] = 'strtomap'
required_args: 't.ClassVar[set[str]]' = {'this'}
218class String(Expression, Func):
219    arg_types = {"this": True, "zone": False}
arg_types = {'this': True, 'zone': False}
key: ClassVar[str] = 'string'
required_args: 't.ClassVar[set[str]]' = {'this'}
222class Stuff(Expression, Func):
223    _sql_names = ["STUFF", "INSERT"]
224    arg_types = {"this": True, "start": True, "length": True, "expression": True}
arg_types = {'this': True, 'start': True, 'length': True, 'expression': True}
key: ClassVar[str] = 'stuff'
required_args: 't.ClassVar[set[str]]' = {'expression', 'start', 'this', 'length'}
227class Substring(Expression, Func):
228    _sql_names = ["SUBSTRING", "SUBSTR"]
229    arg_types = {"this": True, "start": False, "length": False, "zero_start": False}
arg_types = {'this': True, 'start': False, 'length': False, 'zero_start': False}
key: ClassVar[str] = 'substring'
required_args: 't.ClassVar[set[str]]' = {'this'}
232class SubstringIndex(Expression, Func):
233    """
234    SUBSTRING_INDEX(str, delim, count)
235
236    *count* > 0  → left slice before the *count*-th delimiter
237    *count* < 0  → right slice after the |count|-th delimiter
238    """
239
240    arg_types = {"this": True, "delimiter": True, "count": True}

SUBSTRING_INDEX(str, delim, count)

count > 0 → left slice before the count-th delimiter count < 0 → right slice after the |count|-th delimiter

arg_types = {'this': True, 'delimiter': True, 'count': True}
key: ClassVar[str] = 'substringindex'
required_args: 't.ClassVar[set[str]]' = {'this', 'count', 'delimiter'}
243class Translate(Expression, Func):
244    arg_types = {"this": True, "from_": True, "to": True}
arg_types = {'this': True, 'from_': True, 'to': True}
key: ClassVar[str] = 'translate'
required_args: 't.ClassVar[set[str]]' = {'to', 'this', 'from_'}
247class Trim(Expression, Func):
248    arg_types = {
249        "this": True,
250        "expression": False,
251        "position": False,
252        "collation": False,
253    }
arg_types = {'this': True, 'expression': False, 'position': False, 'collation': False}
key: ClassVar[str] = 'trim'
required_args: 't.ClassVar[set[str]]' = {'this'}
256class Unicode(Expression, Func):
257    arg_types = {"this": True, "empty_is_zero": False}
arg_types = {'this': True, 'empty_is_zero': False}
key: ClassVar[str] = 'unicode'
required_args: 't.ClassVar[set[str]]' = {'this'}
260class Upper(Expression, Func):
261    _sql_names = ["UPPER", "UCASE"]
key: ClassVar[str] = 'upper'
required_args: 't.ClassVar[set[str]]' = {'this'}
264class WeightString(Expression, Func):
265    arg_types = {"this": True, "to": False}
arg_types = {'this': True, 'to': False}
key: ClassVar[str] = 'weightstring'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Base64DecodeBinary(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
271class Base64DecodeBinary(Expression, Func):
272    arg_types = {"this": True, "alphabet": False}
arg_types = {'this': True, 'alphabet': False}
key: ClassVar[str] = 'base64decodebinary'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Base64DecodeString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
275class Base64DecodeString(Expression, Func):
276    arg_types = {"this": True, "alphabet": False}
arg_types = {'this': True, 'alphabet': False}
key: ClassVar[str] = 'base64decodestring'
required_args: 't.ClassVar[set[str]]' = {'this'}
279class Base64Encode(Expression, Func):
280    arg_types = {"this": True, "max_line_length": False, "alphabet": False}
arg_types = {'this': True, 'max_line_length': False, 'alphabet': False}
key: ClassVar[str] = 'base64encode'
required_args: 't.ClassVar[set[str]]' = {'this'}
283class CodePointsToBytes(Expression, Func):
284    pass
key: ClassVar[str] = 'codepointstobytes'
required_args: 't.ClassVar[set[str]]' = {'this'}
class CodePointsToString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
287class CodePointsToString(Expression, Func):
288    pass
key: ClassVar[str] = 'codepointstostring'
required_args: 't.ClassVar[set[str]]' = {'this'}
291class ConvertToCharset(Expression, Func):
292    arg_types = {"this": True, "dest": True, "source": False}
arg_types = {'this': True, 'dest': True, 'source': False}
key: ClassVar[str] = 'converttocharset'
required_args: 't.ClassVar[set[str]]' = {'this', 'dest'}
295class Decode(Expression, Func):
296    arg_types = {"this": True, "charset": True, "replace": False}
arg_types = {'this': True, 'charset': True, 'replace': False}
key: ClassVar[str] = 'decode'
required_args: 't.ClassVar[set[str]]' = {'this', 'charset'}
299class Encode(Expression, Func):
300    arg_types = {"this": True, "charset": True}
arg_types = {'this': True, 'charset': True}
key: ClassVar[str] = 'encode'
required_args: 't.ClassVar[set[str]]' = {'this', 'charset'}
303class FromBase(Expression, Func):
304    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'frombase'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
307class FromBase32(Expression, Func):
308    pass
key: ClassVar[str] = 'frombase32'
required_args: 't.ClassVar[set[str]]' = {'this'}
311class FromBase64(Expression, Func):
312    pass
key: ClassVar[str] = 'frombase64'
required_args: 't.ClassVar[set[str]]' = {'this'}
315class Hex(Expression, Func):
316    arg_types = {"this": True, "case": False}
arg_types = {'this': True, 'case': False}
key: ClassVar[str] = 'hex'
required_args: 't.ClassVar[set[str]]' = {'this'}
319class HexDecodeString(Expression, Func):
320    pass
key: ClassVar[str] = 'hexdecodestring'
required_args: 't.ClassVar[set[str]]' = {'this'}
class LowerHex(Hex):
323class LowerHex(Hex):
324    pass
key: ClassVar[str] = 'lowerhex'
required_args: 't.ClassVar[set[str]]' = {'this'}
class SafeConvertBytesToString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
327class SafeConvertBytesToString(Expression, Func):
328    pass
key: ClassVar[str] = 'safeconvertbytestostring'
required_args: 't.ClassVar[set[str]]' = {'this'}
331class ToBase32(Expression, Func):
332    pass
key: ClassVar[str] = 'tobase32'
required_args: 't.ClassVar[set[str]]' = {'this'}
335class ToBase64(Expression, Func):
336    pass
key: ClassVar[str] = 'tobase64'
required_args: 't.ClassVar[set[str]]' = {'this'}
339class ToBinary(Expression, Func):
340    arg_types = {"this": True, "format": False, "safe": False}
arg_types = {'this': True, 'format': False, 'safe': False}
key: ClassVar[str] = 'tobinary'
required_args: 't.ClassVar[set[str]]' = {'this'}
343class ToChar(Expression, Func):
344    arg_types = {
345        "this": True,
346        "format": False,
347        "nlsparam": False,
348        "is_numeric": False,
349    }
arg_types = {'this': True, 'format': False, 'nlsparam': False, 'is_numeric': False}
key: ClassVar[str] = 'tochar'
required_args: 't.ClassVar[set[str]]' = {'this'}
352class ToCodePoints(Expression, Func):
353    pass
key: ClassVar[str] = 'tocodepoints'
required_args: 't.ClassVar[set[str]]' = {'this'}
356class ToDecfloat(Expression, Func):
357    arg_types = {
358        "this": True,
359        "format": False,
360    }
arg_types = {'this': True, 'format': False}
key: ClassVar[str] = 'todecfloat'
required_args: 't.ClassVar[set[str]]' = {'this'}
363class ToDouble(Expression, Func):
364    arg_types = {
365        "this": True,
366        "format": False,
367        "safe": False,
368    }
arg_types = {'this': True, 'format': False, 'safe': False}
key: ClassVar[str] = 'todouble'
required_args: 't.ClassVar[set[str]]' = {'this'}
371class ToFile(Expression, Func):
372    arg_types = {
373        "this": True,
374        "path": False,
375        "safe": False,
376    }
arg_types = {'this': True, 'path': False, 'safe': False}
key: ClassVar[str] = 'tofile'
required_args: 't.ClassVar[set[str]]' = {'this'}
379class ToNumber(Expression, Func):
380    arg_types = {
381        "this": True,
382        "format": False,
383        "nlsparam": False,
384        "precision": False,
385        "scale": False,
386        "safe": False,
387        "safe_name": False,
388        "default": False,
389    }
arg_types = {'this': True, 'format': False, 'nlsparam': False, 'precision': False, 'scale': False, 'safe': False, 'safe_name': False, 'default': False}
key: ClassVar[str] = 'tonumber'
required_args: 't.ClassVar[set[str]]' = {'this'}
class TryBase64DecodeBinary(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
392class TryBase64DecodeBinary(Expression, Func):
393    arg_types = {"this": True, "alphabet": False}
arg_types = {'this': True, 'alphabet': False}
key: ClassVar[str] = 'trybase64decodebinary'
required_args: 't.ClassVar[set[str]]' = {'this'}
class TryBase64DecodeString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
396class TryBase64DecodeString(Expression, Func):
397    arg_types = {"this": True, "alphabet": False}
arg_types = {'this': True, 'alphabet': False}
key: ClassVar[str] = 'trybase64decodestring'
required_args: 't.ClassVar[set[str]]' = {'this'}
class TryHexDecodeBinary(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
400class TryHexDecodeBinary(Expression, Func):
401    pass
key: ClassVar[str] = 'tryhexdecodebinary'
required_args: 't.ClassVar[set[str]]' = {'this'}
class TryHexDecodeString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
404class TryHexDecodeString(Expression, Func):
405    pass
key: ClassVar[str] = 'tryhexdecodestring'
required_args: 't.ClassVar[set[str]]' = {'this'}
408class TryToDecfloat(Expression, Func):
409    arg_types = {
410        "this": True,
411        "format": False,
412    }
arg_types = {'this': True, 'format': False}
key: ClassVar[str] = 'trytodecfloat'
required_args: 't.ClassVar[set[str]]' = {'this'}
415class Unhex(Expression, Func):
416    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'unhex'
required_args: 't.ClassVar[set[str]]' = {'this'}
422class RegexpCount(Expression, Func):
423    arg_types = {
424        "this": True,
425        "expression": True,
426        "position": False,
427        "parameters": False,
428    }
arg_types = {'this': True, 'expression': True, 'position': False, 'parameters': False}
key: ClassVar[str] = 'regexpcount'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
431class RegexpExtract(Expression, Func):
432    arg_types = {
433        "this": True,
434        "expression": True,
435        "position": False,
436        "occurrence": False,
437        "parameters": False,
438        "group": False,
439        "null_if_pos_overflow": False,  # for transpilation target behavior
440    }
arg_types = {'this': True, 'expression': True, 'position': False, 'occurrence': False, 'parameters': False, 'group': False, 'null_if_pos_overflow': False}
key: ClassVar[str] = 'regexpextract'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
443class RegexpExtractAll(Expression, Func):
444    arg_types = {
445        "this": True,
446        "expression": True,
447        "group": False,
448        "parameters": False,
449        "position": False,
450        "occurrence": False,
451    }
arg_types = {'this': True, 'expression': True, 'group': False, 'parameters': False, 'position': False, 'occurrence': False}
key: ClassVar[str] = 'regexpextractall'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
454class RegexpFullMatch(Expression, Binary, Predicate, Func):
455    arg_types = {"this": True, "expression": True, "options": False}
arg_types = {'this': True, 'expression': True, 'options': False}
key: ClassVar[str] = 'regexpfullmatch'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
458class RegexpILike(Expression, Binary, Predicate, Func):
459    arg_types = {"this": True, "expression": True, "flag": False}
arg_types = {'this': True, 'expression': True, 'flag': False}
key: ClassVar[str] = 'regexpilike'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
462class RegexpInstr(Expression, Func):
463    arg_types = {
464        "this": True,
465        "expression": True,
466        "position": False,
467        "occurrence": False,
468        "option": False,
469        "parameters": False,
470        "group": False,
471    }
arg_types = {'this': True, 'expression': True, 'position': False, 'occurrence': False, 'option': False, 'parameters': False, 'group': False}
key: ClassVar[str] = 'regexpinstr'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
474class RegexpReplace(Expression, Func):
475    arg_types = {
476        "this": True,
477        "expression": True,
478        "replacement": False,
479        "position": False,
480        "occurrence": False,
481        "modifiers": False,
482        "single_replace": False,
483    }
arg_types = {'this': True, 'expression': True, 'replacement': False, 'position': False, 'occurrence': False, 'modifiers': False, 'single_replace': False}
key: ClassVar[str] = 'regexpreplace'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
486class RegexpSplit(Expression, Func):
487    # "mode" is Dremio-specific, appended after "limit" for from_arg_list compat
488    arg_types = {"this": True, "expression": True, "limit": False, "mode": False}
arg_types = {'this': True, 'expression': True, 'limit': False, 'mode': False}
key: ClassVar[str] = 'regexpsplit'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
491class RegexpSubstr(Expression, Func):
492    arg_types = {
493        "this": True,
494        "expression": True,
495        "position": False,
496        "occurrence": False,
497        "parameters": False,
498        "group": False,
499    }
arg_types = {'this': True, 'expression': True, 'position': False, 'occurrence': False, 'parameters': False, 'group': False}
key: ClassVar[str] = 'regexpsubstr'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
505class Compress(Expression, Func):
506    arg_types = {"this": True, "method": False}
arg_types = {'this': True, 'method': False}
key: ClassVar[str] = 'compress'
required_args: 't.ClassVar[set[str]]' = {'this'}
509class Decrypt(Expression, Func):
510    arg_types = {
511        "this": True,
512        "passphrase": True,
513        "aad": False,
514        "encryption_method": False,
515        "safe": False,
516    }
arg_types = {'this': True, 'passphrase': True, 'aad': False, 'encryption_method': False, 'safe': False}
key: ClassVar[str] = 'decrypt'
required_args: 't.ClassVar[set[str]]' = {'this', 'passphrase'}
519class DecryptRaw(Expression, Func):
520    arg_types = {
521        "this": True,
522        "key": True,
523        "iv": True,
524        "aad": False,
525        "encryption_method": False,
526        "aead": False,
527        "safe": False,
528    }
arg_types = {'this': True, 'key': True, 'iv': True, 'aad': False, 'encryption_method': False, 'aead': False, 'safe': False}
key: ClassVar[str] = 'decryptraw'
required_args: 't.ClassVar[set[str]]' = {'this', 'key', 'iv'}
531class DecompressBinary(Expression, Func):
532    arg_types = {"this": True, "method": True}
arg_types = {'this': True, 'method': True}
key: ClassVar[str] = 'decompressbinary'
required_args: 't.ClassVar[set[str]]' = {'method', 'this'}
535class DecompressString(Expression, Func):
536    arg_types = {"this": True, "method": True}
arg_types = {'this': True, 'method': True}
key: ClassVar[str] = 'decompressstring'
required_args: 't.ClassVar[set[str]]' = {'method', 'this'}
539class Encrypt(Expression, Func):
540    arg_types = {"this": True, "passphrase": True, "aad": False, "encryption_method": False}
arg_types = {'this': True, 'passphrase': True, 'aad': False, 'encryption_method': False}
key: ClassVar[str] = 'encrypt'
required_args: 't.ClassVar[set[str]]' = {'this', 'passphrase'}
543class EncryptRaw(Expression, Func):
544    arg_types = {"this": True, "key": True, "iv": True, "aad": False, "encryption_method": False}
arg_types = {'this': True, 'key': True, 'iv': True, 'aad': False, 'encryption_method': False}
key: ClassVar[str] = 'encryptraw'
required_args: 't.ClassVar[set[str]]' = {'this', 'key', 'iv'}
547class CityHash64(Expression, Func):
548    arg_types = {"expressions": False}
549    is_var_len_args = True
arg_types = {'expressions': False}
is_var_len_args = True
key: ClassVar[str] = 'cityhash64'
required_args: 't.ClassVar[set[str]]' = set()
552class FarmFingerprint(Expression, Func):
553    arg_types = {"expressions": True}
554    is_var_len_args = True
555    _sql_names = ["FARM_FINGERPRINT", "FARMFINGERPRINT64"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'farmfingerprint'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
558class MD5(Expression, Func):
559    _sql_names = ["MD5"]
key: ClassVar[str] = 'md5'
required_args: 't.ClassVar[set[str]]' = {'this'}
562class MD5Digest(Expression, Func):
563    arg_types = {"this": True, "expressions": False}
564    is_var_len_args = True
565    _sql_names = ["MD5_DIGEST"]
arg_types = {'this': True, 'expressions': False}
is_var_len_args = True
key: ClassVar[str] = 'md5digest'
required_args: 't.ClassVar[set[str]]' = {'this'}
568class MD5NumberLower64(Expression, Func):
569    pass
key: ClassVar[str] = 'md5numberlower64'
required_args: 't.ClassVar[set[str]]' = {'this'}
572class MD5NumberUpper64(Expression, Func):
573    pass
key: ClassVar[str] = 'md5numberupper64'
required_args: 't.ClassVar[set[str]]' = {'this'}
576class SHA(Expression, Func):
577    _sql_names = ["SHA", "SHA1"]
key: ClassVar[str] = 'sha'
required_args: 't.ClassVar[set[str]]' = {'this'}
580class SHA1Digest(Expression, Func):
581    pass
key: ClassVar[str] = 'sha1digest'
required_args: 't.ClassVar[set[str]]' = {'this'}
584class SHA2(Expression, Func):
585    _sql_names = ["SHA2"]
586    arg_types = {"this": True, "length": False}
arg_types = {'this': True, 'length': False}
key: ClassVar[str] = 'sha2'
required_args: 't.ClassVar[set[str]]' = {'this'}
589class SHA2Digest(Expression, Func):
590    arg_types = {"this": True, "length": False}
arg_types = {'this': True, 'length': False}
key: ClassVar[str] = 'sha2digest'
required_args: 't.ClassVar[set[str]]' = {'this'}
593class StandardHash(Expression, Func):
594    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'standardhash'
required_args: 't.ClassVar[set[str]]' = {'this'}
600class ParseBignumeric(Expression, Func):
601    pass
key: ClassVar[str] = 'parsebignumeric'
required_args: 't.ClassVar[set[str]]' = {'this'}
604class ParseNumeric(Expression, Func):
605    pass
key: ClassVar[str] = 'parsenumeric'
required_args: 't.ClassVar[set[str]]' = {'this'}
608class ParseUrl(Expression, Func):
609    arg_types = {"this": True, "part_to_extract": False, "key": False, "permissive": False}
arg_types = {'this': True, 'part_to_extract': False, 'key': False, 'permissive': False}
key: ClassVar[str] = 'parseurl'
required_args: 't.ClassVar[set[str]]' = {'this'}