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

SPACE(n) → string consisting of n blank characters

key: ClassVar[str] = 'space'
required_args: 't.ClassVar[set[str]]' = {'this'}
161class Split(Expression, Func):
162    arg_types = {
163        "this": True,
164        "expression": True,
165        "limit": False,
166        "null_returns_null": False,
167        "empty_delimiter_returns_whole": False,
168    }
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'}
171class SplitPart(Expression, Func):
172    arg_types = {
173        "this": True,
174        "delimiter": False,
175        "part_index": False,
176        "part_index_zero_as_one": False,  # usually part_index is 1-based, however Snowflake allows 0 and treats it as 1
177        "empty_delimiter_returns_whole": False,  # whether the whole input string should be returned if the delimiter string is empty (i.e. Snowflake)
178    }
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'}
181class Strtok(Expression, Func):
182    arg_types = {
183        "this": True,
184        "delimiter": False,
185        "part_index": False,
186    }
arg_types = {'this': True, 'delimiter': False, 'part_index': False}
key: ClassVar[str] = 'strtok'
required_args: 't.ClassVar[set[str]]' = {'this'}
189class StartsWith(Expression, Func):
190    _sql_names = ["STARTS_WITH", "STARTSWITH"]
191    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'startswith'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
194class StrPosition(Expression, Func):
195    arg_types = {
196        "this": True,
197        "substr": True,
198        "position": False,
199        "occurrence": False,
200        "clamp_position": False,
201    }
arg_types = {'this': True, 'substr': True, 'position': False, 'occurrence': False, 'clamp_position': False}
key: ClassVar[str] = 'strposition'
required_args: 't.ClassVar[set[str]]' = {'substr', 'this'}
204class StrToMap(Expression, Func):
205    arg_types = {
206        "this": True,
207        "pair_delim": False,
208        "key_value_delim": False,
209        "duplicate_resolution_callback": False,
210    }
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'}
213class String(Expression, Func):
214    arg_types = {"this": True, "zone": False}
arg_types = {'this': True, 'zone': False}
key: ClassVar[str] = 'string'
required_args: 't.ClassVar[set[str]]' = {'this'}
217class Stuff(Expression, Func):
218    _sql_names = ["STUFF", "INSERT"]
219    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'}
222class Substring(Expression, Func):
223    _sql_names = ["SUBSTRING", "SUBSTR"]
224    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'}
227class SubstringIndex(Expression, Func):
228    """
229    SUBSTRING_INDEX(str, delim, count)
230
231    *count* > 0  → left slice before the *count*-th delimiter
232    *count* < 0  → right slice after the |count|-th delimiter
233    """
234
235    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]]' = {'delimiter', 'count', 'this'}
238class Translate(Expression, Func):
239    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', 'from_', 'this'}
242class Trim(Expression, Func):
243    arg_types = {
244        "this": True,
245        "expression": False,
246        "position": False,
247        "collation": False,
248    }
arg_types = {'this': True, 'expression': False, 'position': False, 'collation': False}
key: ClassVar[str] = 'trim'
required_args: 't.ClassVar[set[str]]' = {'this'}
251class Unicode(Expression, Func):
252    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'}
255class Upper(Expression, Func):
256    _sql_names = ["UPPER", "UCASE"]
key: ClassVar[str] = 'upper'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Base64DecodeBinary(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
262class Base64DecodeBinary(Expression, Func):
263    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):
266class Base64DecodeString(Expression, Func):
267    arg_types = {"this": True, "alphabet": False}
arg_types = {'this': True, 'alphabet': False}
key: ClassVar[str] = 'base64decodestring'
required_args: 't.ClassVar[set[str]]' = {'this'}
270class Base64Encode(Expression, Func):
271    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'}
274class CodePointsToBytes(Expression, Func):
275    pass
key: ClassVar[str] = 'codepointstobytes'
required_args: 't.ClassVar[set[str]]' = {'this'}
class CodePointsToString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
278class CodePointsToString(Expression, Func):
279    pass
key: ClassVar[str] = 'codepointstostring'
required_args: 't.ClassVar[set[str]]' = {'this'}
282class ConvertToCharset(Expression, Func):
283    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]]' = {'dest', 'this'}
286class Decode(Expression, Func):
287    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]]' = {'charset', 'this'}
290class Encode(Expression, Func):
291    arg_types = {"this": True, "charset": True}
arg_types = {'this': True, 'charset': True}
key: ClassVar[str] = 'encode'
required_args: 't.ClassVar[set[str]]' = {'charset', 'this'}
294class FromBase(Expression, Func):
295    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'frombase'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
298class FromBase32(Expression, Func):
299    pass
key: ClassVar[str] = 'frombase32'
required_args: 't.ClassVar[set[str]]' = {'this'}
302class FromBase64(Expression, Func):
303    pass
key: ClassVar[str] = 'frombase64'
required_args: 't.ClassVar[set[str]]' = {'this'}
306class Hex(Expression, Func):
307    pass
key: ClassVar[str] = 'hex'
required_args: 't.ClassVar[set[str]]' = {'this'}
310class HexDecodeString(Expression, Func):
311    pass
key: ClassVar[str] = 'hexdecodestring'
required_args: 't.ClassVar[set[str]]' = {'this'}
314class HexEncode(Expression, Func):
315    arg_types = {"this": True, "case": False}
arg_types = {'this': True, 'case': False}
key: ClassVar[str] = 'hexencode'
required_args: 't.ClassVar[set[str]]' = {'this'}
class LowerHex(Hex):
318class LowerHex(Hex):
319    pass
key: ClassVar[str] = 'lowerhex'
required_args: 't.ClassVar[set[str]]' = {'this'}
class SafeConvertBytesToString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
322class SafeConvertBytesToString(Expression, Func):
323    pass
key: ClassVar[str] = 'safeconvertbytestostring'
required_args: 't.ClassVar[set[str]]' = {'this'}
326class ToBase32(Expression, Func):
327    pass
key: ClassVar[str] = 'tobase32'
required_args: 't.ClassVar[set[str]]' = {'this'}
330class ToBase64(Expression, Func):
331    pass
key: ClassVar[str] = 'tobase64'
required_args: 't.ClassVar[set[str]]' = {'this'}
334class ToBinary(Expression, Func):
335    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'}
338class ToChar(Expression, Func):
339    arg_types = {
340        "this": True,
341        "format": False,
342        "nlsparam": False,
343        "is_numeric": False,
344    }
arg_types = {'this': True, 'format': False, 'nlsparam': False, 'is_numeric': False}
key: ClassVar[str] = 'tochar'
required_args: 't.ClassVar[set[str]]' = {'this'}
347class ToCodePoints(Expression, Func):
348    pass
key: ClassVar[str] = 'tocodepoints'
required_args: 't.ClassVar[set[str]]' = {'this'}
351class ToDecfloat(Expression, Func):
352    arg_types = {
353        "this": True,
354        "format": False,
355    }
arg_types = {'this': True, 'format': False}
key: ClassVar[str] = 'todecfloat'
required_args: 't.ClassVar[set[str]]' = {'this'}
358class ToDouble(Expression, Func):
359    arg_types = {
360        "this": True,
361        "format": False,
362        "safe": False,
363    }
arg_types = {'this': True, 'format': False, 'safe': False}
key: ClassVar[str] = 'todouble'
required_args: 't.ClassVar[set[str]]' = {'this'}
366class ToFile(Expression, Func):
367    arg_types = {
368        "this": True,
369        "path": False,
370        "safe": False,
371    }
arg_types = {'this': True, 'path': False, 'safe': False}
key: ClassVar[str] = 'tofile'
required_args: 't.ClassVar[set[str]]' = {'this'}
374class ToNumber(Expression, Func):
375    arg_types = {
376        "this": True,
377        "format": False,
378        "nlsparam": False,
379        "precision": False,
380        "scale": False,
381        "safe": False,
382        "safe_name": False,
383    }
arg_types = {'this': True, 'format': False, 'nlsparam': False, 'precision': False, 'scale': False, 'safe': False, 'safe_name': False}
key: ClassVar[str] = 'tonumber'
required_args: 't.ClassVar[set[str]]' = {'this'}
class TryBase64DecodeBinary(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
386class TryBase64DecodeBinary(Expression, Func):
387    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):
390class TryBase64DecodeString(Expression, Func):
391    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):
394class TryHexDecodeBinary(Expression, Func):
395    pass
key: ClassVar[str] = 'tryhexdecodebinary'
required_args: 't.ClassVar[set[str]]' = {'this'}
class TryHexDecodeString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
398class TryHexDecodeString(Expression, Func):
399    pass
key: ClassVar[str] = 'tryhexdecodestring'
required_args: 't.ClassVar[set[str]]' = {'this'}
402class TryToDecfloat(Expression, Func):
403    arg_types = {
404        "this": True,
405        "format": False,
406    }
arg_types = {'this': True, 'format': False}
key: ClassVar[str] = 'trytodecfloat'
required_args: 't.ClassVar[set[str]]' = {'this'}
409class Unhex(Expression, Func):
410    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'unhex'
required_args: 't.ClassVar[set[str]]' = {'this'}
416class RegexpCount(Expression, Func):
417    arg_types = {
418        "this": True,
419        "expression": True,
420        "position": False,
421        "parameters": False,
422    }
arg_types = {'this': True, 'expression': True, 'position': False, 'parameters': False}
key: ClassVar[str] = 'regexpcount'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
425class RegexpExtract(Expression, Func):
426    arg_types = {
427        "this": True,
428        "expression": True,
429        "position": False,
430        "occurrence": False,
431        "parameters": False,
432        "group": False,
433        "null_if_pos_overflow": False,  # for transpilation target behavior
434    }
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'}
437class RegexpExtractAll(Expression, Func):
438    arg_types = {
439        "this": True,
440        "expression": True,
441        "group": False,
442        "parameters": False,
443        "position": False,
444        "occurrence": False,
445    }
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'}
448class RegexpFullMatch(Expression, Binary, Func):
449    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'}
452class RegexpILike(Expression, Binary, Func):
453    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'}
456class RegexpInstr(Expression, Func):
457    arg_types = {
458        "this": True,
459        "expression": True,
460        "position": False,
461        "occurrence": False,
462        "option": False,
463        "parameters": False,
464        "group": False,
465    }
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'}
468class RegexpReplace(Expression, Func):
469    arg_types = {
470        "this": True,
471        "expression": True,
472        "replacement": False,
473        "position": False,
474        "occurrence": False,
475        "modifiers": False,
476        "single_replace": False,
477    }
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'}
480class RegexpSplit(Expression, Func):
481    arg_types = {"this": True, "expression": True, "limit": False}
arg_types = {'this': True, 'expression': True, 'limit': False}
key: ClassVar[str] = 'regexpsplit'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
487class Compress(Expression, Func):
488    arg_types = {"this": True, "method": False}
arg_types = {'this': True, 'method': False}
key: ClassVar[str] = 'compress'
required_args: 't.ClassVar[set[str]]' = {'this'}
491class Decrypt(Expression, Func):
492    arg_types = {
493        "this": True,
494        "passphrase": True,
495        "aad": False,
496        "encryption_method": False,
497        "safe": False,
498    }
arg_types = {'this': True, 'passphrase': True, 'aad': False, 'encryption_method': False, 'safe': False}
key: ClassVar[str] = 'decrypt'
required_args: 't.ClassVar[set[str]]' = {'passphrase', 'this'}
501class DecryptRaw(Expression, Func):
502    arg_types = {
503        "this": True,
504        "key": True,
505        "iv": True,
506        "aad": False,
507        "encryption_method": False,
508        "aead": False,
509        "safe": False,
510    }
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]]' = {'iv', 'key', 'this'}
513class DecompressBinary(Expression, Func):
514    arg_types = {"this": True, "method": True}
arg_types = {'this': True, 'method': True}
key: ClassVar[str] = 'decompressbinary'
required_args: 't.ClassVar[set[str]]' = {'this', 'method'}
517class DecompressString(Expression, Func):
518    arg_types = {"this": True, "method": True}
arg_types = {'this': True, 'method': True}
key: ClassVar[str] = 'decompressstring'
required_args: 't.ClassVar[set[str]]' = {'this', 'method'}
521class Encrypt(Expression, Func):
522    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]]' = {'passphrase', 'this'}
525class EncryptRaw(Expression, Func):
526    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]]' = {'iv', 'key', 'this'}
529class CityHash64(Expression, Func):
530    arg_types = {"expressions": False}
531    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()
534class FarmFingerprint(Expression, Func):
535    arg_types = {"expressions": True}
536    is_var_len_args = True
537    _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'}
540class MD5(Expression, Func):
541    _sql_names = ["MD5"]
key: ClassVar[str] = 'md5'
required_args: 't.ClassVar[set[str]]' = {'this'}
544class MD5Digest(Expression, Func):
545    arg_types = {"this": True, "expressions": False}
546    is_var_len_args = True
547    _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'}
550class MD5NumberLower64(Expression, Func):
551    pass
key: ClassVar[str] = 'md5numberlower64'
required_args: 't.ClassVar[set[str]]' = {'this'}
554class MD5NumberUpper64(Expression, Func):
555    pass
key: ClassVar[str] = 'md5numberupper64'
required_args: 't.ClassVar[set[str]]' = {'this'}
558class SHA(Expression, Func):
559    _sql_names = ["SHA", "SHA1"]
key: ClassVar[str] = 'sha'
required_args: 't.ClassVar[set[str]]' = {'this'}
562class SHA1Digest(Expression, Func):
563    pass
key: ClassVar[str] = 'sha1digest'
required_args: 't.ClassVar[set[str]]' = {'this'}
566class SHA2(Expression, Func):
567    _sql_names = ["SHA2"]
568    arg_types = {"this": True, "length": False}
arg_types = {'this': True, 'length': False}
key: ClassVar[str] = 'sha2'
required_args: 't.ClassVar[set[str]]' = {'this'}
571class SHA2Digest(Expression, Func):
572    arg_types = {"this": True, "length": False}
arg_types = {'this': True, 'length': False}
key: ClassVar[str] = 'sha2digest'
required_args: 't.ClassVar[set[str]]' = {'this'}
575class StandardHash(Expression, Func):
576    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'standardhash'
required_args: 't.ClassVar[set[str]]' = {'this'}
582class ParseBignumeric(Expression, Func):
583    pass
key: ClassVar[str] = 'parsebignumeric'
required_args: 't.ClassVar[set[str]]' = {'this'}
586class ParseNumeric(Expression, Func):
587    pass
key: ClassVar[str] = 'parsenumeric'
required_args: 't.ClassVar[set[str]]' = {'this'}
590class ParseUrl(Expression, Func):
591    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'}