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 Secret(Expression, Func):
145    arg_types = {"this": True, "expression": True}
146
147
148class Soundex(Expression, Func):
149    pass
150
151
152class SoundexP123(Expression, Func):
153    pass
154
155
156class Space(Expression, Func):
157    """
158    SPACE(n) → string consisting of n blank characters
159    """
160
161    pass
162
163
164class Split(Expression, Func):
165    arg_types = {
166        "this": True,
167        "expression": True,
168        "limit": False,
169        "null_returns_null": False,
170        "empty_delimiter_returns_whole": False,
171    }
172
173
174class SplitPart(Expression, Func):
175    arg_types = {
176        "this": True,
177        "delimiter": False,
178        "part_index": False,
179        "part_index_zero_as_one": False,  # usually part_index is 1-based, however Snowflake allows 0 and treats it as 1
180        "empty_delimiter_returns_whole": False,  # whether the whole input string should be returned if the delimiter string is empty (i.e. Snowflake)
181    }
182
183
184class Strtok(Expression, Func):
185    arg_types = {
186        "this": True,
187        "delimiter": False,
188        "part_index": False,
189    }
190
191
192class StartsWith(Expression, Func):
193    _sql_names = ["STARTS_WITH", "STARTSWITH"]
194    arg_types = {"this": True, "expression": True}
195
196
197class StrPosition(Expression, Func):
198    arg_types = {
199        "this": True,
200        "substr": True,
201        "position": False,
202        "occurrence": False,
203        "clamp_position": False,
204    }
205
206
207class StrToMap(Expression, Func):
208    arg_types = {
209        "this": True,
210        "pair_delim": False,
211        "key_value_delim": False,
212        "duplicate_resolution_callback": False,
213    }
214
215
216class String(Expression, Func):
217    arg_types = {"this": True, "zone": False}
218
219
220class Stuff(Expression, Func):
221    _sql_names = ["STUFF", "INSERT"]
222    arg_types = {"this": True, "start": True, "length": True, "expression": True}
223
224
225class Substring(Expression, Func):
226    _sql_names = ["SUBSTRING", "SUBSTR"]
227    arg_types = {"this": True, "start": False, "length": False, "zero_start": False}
228
229
230class SubstringIndex(Expression, Func):
231    """
232    SUBSTRING_INDEX(str, delim, count)
233
234    *count* > 0  → left slice before the *count*-th delimiter
235    *count* < 0  → right slice after the |count|-th delimiter
236    """
237
238    arg_types = {"this": True, "delimiter": True, "count": True}
239
240
241class Translate(Expression, Func):
242    arg_types = {"this": True, "from_": True, "to": True}
243
244
245class Trim(Expression, Func):
246    arg_types = {
247        "this": True,
248        "expression": False,
249        "position": False,
250        "collation": False,
251    }
252
253
254class Unicode(Expression, Func):
255    arg_types = {"this": True, "empty_is_zero": False}
256
257
258class Upper(Expression, Func):
259    _sql_names = ["UPPER", "UCASE"]
260
261
262# Encoding / base conversion
263
264
265class Base64DecodeBinary(Expression, Func):
266    arg_types = {"this": True, "alphabet": False}
267
268
269class Base64DecodeString(Expression, Func):
270    arg_types = {"this": True, "alphabet": False}
271
272
273class Base64Encode(Expression, Func):
274    arg_types = {"this": True, "max_line_length": False, "alphabet": False}
275
276
277class CodePointsToBytes(Expression, Func):
278    pass
279
280
281class CodePointsToString(Expression, Func):
282    pass
283
284
285class ConvertToCharset(Expression, Func):
286    arg_types = {"this": True, "dest": True, "source": False}
287
288
289class Decode(Expression, Func):
290    arg_types = {"this": True, "charset": True, "replace": False}
291
292
293class Encode(Expression, Func):
294    arg_types = {"this": True, "charset": True}
295
296
297class FromBase(Expression, Func):
298    arg_types = {"this": True, "expression": True}
299
300
301class FromBase32(Expression, Func):
302    pass
303
304
305class FromBase64(Expression, Func):
306    pass
307
308
309class Hex(Expression, Func):
310    arg_types = {"this": True, "case": False}
311
312
313class HexDecodeString(Expression, Func):
314    pass
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        "default": False,
383    }
384
385
386class TryBase64DecodeBinary(Expression, Func):
387    arg_types = {"this": True, "alphabet": False}
388
389
390class TryBase64DecodeString(Expression, Func):
391    arg_types = {"this": True, "alphabet": False}
392
393
394class TryHexDecodeBinary(Expression, Func):
395    pass
396
397
398class TryHexDecodeString(Expression, Func):
399    pass
400
401
402class TryToDecfloat(Expression, Func):
403    arg_types = {
404        "this": True,
405        "format": False,
406    }
407
408
409class Unhex(Expression, Func):
410    arg_types = {"this": True, "expression": False}
411
412
413# Regex
414
415
416class RegexpCount(Expression, Func):
417    arg_types = {
418        "this": True,
419        "expression": True,
420        "position": False,
421        "parameters": False,
422    }
423
424
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    }
435
436
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    }
446
447
448class RegexpFullMatch(Expression, Binary, Func):
449    arg_types = {"this": True, "expression": True, "options": False}
450
451
452class RegexpILike(Expression, Binary, Func):
453    arg_types = {"this": True, "expression": True, "flag": False}
454
455
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    }
466
467
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    }
478
479
480class RegexpSplit(Expression, Func):
481    arg_types = {"this": True, "expression": True, "limit": False}
482
483
484class RegexpSubstr(Expression, Func):
485    arg_types = {
486        "this": True,
487        "expression": True,
488        "position": False,
489        "occurrence": False,
490        "parameters": False,
491        "group": False,
492    }
493
494
495# Hashing / cryptographic
496
497
498class Compress(Expression, Func):
499    arg_types = {"this": True, "method": False}
500
501
502class Decrypt(Expression, Func):
503    arg_types = {
504        "this": True,
505        "passphrase": True,
506        "aad": False,
507        "encryption_method": False,
508        "safe": False,
509    }
510
511
512class DecryptRaw(Expression, Func):
513    arg_types = {
514        "this": True,
515        "key": True,
516        "iv": True,
517        "aad": False,
518        "encryption_method": False,
519        "aead": False,
520        "safe": False,
521    }
522
523
524class DecompressBinary(Expression, Func):
525    arg_types = {"this": True, "method": True}
526
527
528class DecompressString(Expression, Func):
529    arg_types = {"this": True, "method": True}
530
531
532class Encrypt(Expression, Func):
533    arg_types = {"this": True, "passphrase": True, "aad": False, "encryption_method": False}
534
535
536class EncryptRaw(Expression, Func):
537    arg_types = {"this": True, "key": True, "iv": True, "aad": False, "encryption_method": False}
538
539
540class CityHash64(Expression, Func):
541    arg_types = {"expressions": False}
542    is_var_len_args = True
543
544
545class FarmFingerprint(Expression, Func):
546    arg_types = {"expressions": True}
547    is_var_len_args = True
548    _sql_names = ["FARM_FINGERPRINT", "FARMFINGERPRINT64"]
549
550
551class MD5(Expression, Func):
552    _sql_names = ["MD5"]
553
554
555class MD5Digest(Expression, Func):
556    arg_types = {"this": True, "expressions": False}
557    is_var_len_args = True
558    _sql_names = ["MD5_DIGEST"]
559
560
561class MD5NumberLower64(Expression, Func):
562    pass
563
564
565class MD5NumberUpper64(Expression, Func):
566    pass
567
568
569class SHA(Expression, Func):
570    _sql_names = ["SHA", "SHA1"]
571
572
573class SHA1Digest(Expression, Func):
574    pass
575
576
577class SHA2(Expression, Func):
578    _sql_names = ["SHA2"]
579    arg_types = {"this": True, "length": False}
580
581
582class SHA2Digest(Expression, Func):
583    arg_types = {"this": True, "length": False}
584
585
586class StandardHash(Expression, Func):
587    arg_types = {"this": True, "expression": False}
588
589
590# Parse
591
592
593class ParseBignumeric(Expression, Func):
594    pass
595
596
597class ParseNumeric(Expression, Func):
598    pass
599
600
601class ParseUrl(Expression, Func):
602    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]]' = {'expression', 'from_', '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]]' = {'expression', 'is_left', '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 Secret(Expression, Func):
146    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'secret'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
149class Soundex(Expression, Func):
150    pass
key: ClassVar[str] = 'soundex'
required_args: 't.ClassVar[set[str]]' = {'this'}
153class SoundexP123(Expression, Func):
154    pass
key: ClassVar[str] = 'soundexp123'
required_args: 't.ClassVar[set[str]]' = {'this'}
157class Space(Expression, Func):
158    """
159    SPACE(n) → string consisting of n blank characters
160    """
161
162    pass

SPACE(n) → string consisting of n blank characters

key: ClassVar[str] = 'space'
required_args: 't.ClassVar[set[str]]' = {'this'}
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    }
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'}
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    }
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'}
185class Strtok(Expression, Func):
186    arg_types = {
187        "this": True,
188        "delimiter": False,
189        "part_index": False,
190    }
arg_types = {'this': True, 'delimiter': False, 'part_index': False}
key: ClassVar[str] = 'strtok'
required_args: 't.ClassVar[set[str]]' = {'this'}
193class StartsWith(Expression, Func):
194    _sql_names = ["STARTS_WITH", "STARTSWITH"]
195    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'startswith'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
198class StrPosition(Expression, Func):
199    arg_types = {
200        "this": True,
201        "substr": True,
202        "position": False,
203        "occurrence": False,
204        "clamp_position": False,
205    }
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'}
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    }
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'}
217class String(Expression, Func):
218    arg_types = {"this": True, "zone": False}
arg_types = {'this': True, 'zone': False}
key: ClassVar[str] = 'string'
required_args: 't.ClassVar[set[str]]' = {'this'}
221class Stuff(Expression, Func):
222    _sql_names = ["STUFF", "INSERT"]
223    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', 'length', 'this'}
226class Substring(Expression, Func):
227    _sql_names = ["SUBSTRING", "SUBSTR"]
228    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'}
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}

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'}
242class Translate(Expression, Func):
243    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]]' = {'from_', 'to', 'this'}
246class Trim(Expression, Func):
247    arg_types = {
248        "this": True,
249        "expression": False,
250        "position": False,
251        "collation": False,
252    }
arg_types = {'this': True, 'expression': False, 'position': False, 'collation': False}
key: ClassVar[str] = 'trim'
required_args: 't.ClassVar[set[str]]' = {'this'}
255class Unicode(Expression, Func):
256    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'}
259class Upper(Expression, Func):
260    _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):
266class Base64DecodeBinary(Expression, Func):
267    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):
270class Base64DecodeString(Expression, Func):
271    arg_types = {"this": True, "alphabet": False}
arg_types = {'this': True, 'alphabet': False}
key: ClassVar[str] = 'base64decodestring'
required_args: 't.ClassVar[set[str]]' = {'this'}
274class Base64Encode(Expression, Func):
275    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'}
278class CodePointsToBytes(Expression, Func):
279    pass
key: ClassVar[str] = 'codepointstobytes'
required_args: 't.ClassVar[set[str]]' = {'this'}
class CodePointsToString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
282class CodePointsToString(Expression, Func):
283    pass
key: ClassVar[str] = 'codepointstostring'
required_args: 't.ClassVar[set[str]]' = {'this'}
286class ConvertToCharset(Expression, Func):
287    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'}
290class Decode(Expression, Func):
291    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'}
294class Encode(Expression, Func):
295    arg_types = {"this": True, "charset": True}
arg_types = {'this': True, 'charset': True}
key: ClassVar[str] = 'encode'
required_args: 't.ClassVar[set[str]]' = {'charset', 'this'}
298class FromBase(Expression, Func):
299    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'frombase'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
302class FromBase32(Expression, Func):
303    pass
key: ClassVar[str] = 'frombase32'
required_args: 't.ClassVar[set[str]]' = {'this'}
306class FromBase64(Expression, Func):
307    pass
key: ClassVar[str] = 'frombase64'
required_args: 't.ClassVar[set[str]]' = {'this'}
310class Hex(Expression, Func):
311    arg_types = {"this": True, "case": False}
arg_types = {'this': True, 'case': False}
key: ClassVar[str] = 'hex'
required_args: 't.ClassVar[set[str]]' = {'this'}
314class HexDecodeString(Expression, Func):
315    pass
key: ClassVar[str] = 'hexdecodestring'
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        "default": False,
384    }
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):
387class TryBase64DecodeBinary(Expression, Func):
388    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):
391class TryBase64DecodeString(Expression, Func):
392    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):
395class TryHexDecodeBinary(Expression, Func):
396    pass
key: ClassVar[str] = 'tryhexdecodebinary'
required_args: 't.ClassVar[set[str]]' = {'this'}
class TryHexDecodeString(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
399class TryHexDecodeString(Expression, Func):
400    pass
key: ClassVar[str] = 'tryhexdecodestring'
required_args: 't.ClassVar[set[str]]' = {'this'}
403class TryToDecfloat(Expression, Func):
404    arg_types = {
405        "this": True,
406        "format": False,
407    }
arg_types = {'this': True, 'format': False}
key: ClassVar[str] = 'trytodecfloat'
required_args: 't.ClassVar[set[str]]' = {'this'}
410class Unhex(Expression, Func):
411    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'unhex'
required_args: 't.ClassVar[set[str]]' = {'this'}
417class RegexpCount(Expression, Func):
418    arg_types = {
419        "this": True,
420        "expression": True,
421        "position": False,
422        "parameters": False,
423    }
arg_types = {'this': True, 'expression': True, 'position': False, 'parameters': False}
key: ClassVar[str] = 'regexpcount'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
426class RegexpExtract(Expression, Func):
427    arg_types = {
428        "this": True,
429        "expression": True,
430        "position": False,
431        "occurrence": False,
432        "parameters": False,
433        "group": False,
434        "null_if_pos_overflow": False,  # for transpilation target behavior
435    }
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'}
438class RegexpExtractAll(Expression, Func):
439    arg_types = {
440        "this": True,
441        "expression": True,
442        "group": False,
443        "parameters": False,
444        "position": False,
445        "occurrence": False,
446    }
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'}
449class RegexpFullMatch(Expression, Binary, Func):
450    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'}
453class RegexpILike(Expression, Binary, Func):
454    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'}
457class RegexpInstr(Expression, Func):
458    arg_types = {
459        "this": True,
460        "expression": True,
461        "position": False,
462        "occurrence": False,
463        "option": False,
464        "parameters": False,
465        "group": False,
466    }
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'}
469class RegexpReplace(Expression, Func):
470    arg_types = {
471        "this": True,
472        "expression": True,
473        "replacement": False,
474        "position": False,
475        "occurrence": False,
476        "modifiers": False,
477        "single_replace": False,
478    }
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'}
481class RegexpSplit(Expression, Func):
482    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'}
485class RegexpSubstr(Expression, Func):
486    arg_types = {
487        "this": True,
488        "expression": True,
489        "position": False,
490        "occurrence": False,
491        "parameters": False,
492        "group": False,
493    }
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'}
499class Compress(Expression, Func):
500    arg_types = {"this": True, "method": False}
arg_types = {'this': True, 'method': False}
key: ClassVar[str] = 'compress'
required_args: 't.ClassVar[set[str]]' = {'this'}
503class Decrypt(Expression, Func):
504    arg_types = {
505        "this": True,
506        "passphrase": True,
507        "aad": False,
508        "encryption_method": False,
509        "safe": False,
510    }
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'}
513class DecryptRaw(Expression, Func):
514    arg_types = {
515        "this": True,
516        "key": True,
517        "iv": True,
518        "aad": False,
519        "encryption_method": False,
520        "aead": False,
521        "safe": False,
522    }
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'}
525class DecompressBinary(Expression, Func):
526    arg_types = {"this": True, "method": True}
arg_types = {'this': True, 'method': True}
key: ClassVar[str] = 'decompressbinary'
required_args: 't.ClassVar[set[str]]' = {'method', 'this'}
529class DecompressString(Expression, Func):
530    arg_types = {"this": True, "method": True}
arg_types = {'this': True, 'method': True}
key: ClassVar[str] = 'decompressstring'
required_args: 't.ClassVar[set[str]]' = {'method', 'this'}
533class Encrypt(Expression, Func):
534    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'}
537class EncryptRaw(Expression, Func):
538    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'}
541class CityHash64(Expression, Func):
542    arg_types = {"expressions": False}
543    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()
546class FarmFingerprint(Expression, Func):
547    arg_types = {"expressions": True}
548    is_var_len_args = True
549    _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'}
552class MD5(Expression, Func):
553    _sql_names = ["MD5"]
key: ClassVar[str] = 'md5'
required_args: 't.ClassVar[set[str]]' = {'this'}
556class MD5Digest(Expression, Func):
557    arg_types = {"this": True, "expressions": False}
558    is_var_len_args = True
559    _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'}
562class MD5NumberLower64(Expression, Func):
563    pass
key: ClassVar[str] = 'md5numberlower64'
required_args: 't.ClassVar[set[str]]' = {'this'}
566class MD5NumberUpper64(Expression, Func):
567    pass
key: ClassVar[str] = 'md5numberupper64'
required_args: 't.ClassVar[set[str]]' = {'this'}
570class SHA(Expression, Func):
571    _sql_names = ["SHA", "SHA1"]
key: ClassVar[str] = 'sha'
required_args: 't.ClassVar[set[str]]' = {'this'}
574class SHA1Digest(Expression, Func):
575    pass
key: ClassVar[str] = 'sha1digest'
required_args: 't.ClassVar[set[str]]' = {'this'}
578class SHA2(Expression, Func):
579    _sql_names = ["SHA2"]
580    arg_types = {"this": True, "length": False}
arg_types = {'this': True, 'length': False}
key: ClassVar[str] = 'sha2'
required_args: 't.ClassVar[set[str]]' = {'this'}
583class SHA2Digest(Expression, Func):
584    arg_types = {"this": True, "length": False}
arg_types = {'this': True, 'length': False}
key: ClassVar[str] = 'sha2digest'
required_args: 't.ClassVar[set[str]]' = {'this'}
587class StandardHash(Expression, Func):
588    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'standardhash'
required_args: 't.ClassVar[set[str]]' = {'this'}
594class ParseBignumeric(Expression, Func):
595    pass
key: ClassVar[str] = 'parsebignumeric'
required_args: 't.ClassVar[set[str]]' = {'this'}
598class ParseNumeric(Expression, Func):
599    pass
key: ClassVar[str] = 'parsenumeric'
required_args: 't.ClassVar[set[str]]' = {'this'}
602class ParseUrl(Expression, Func):
603    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'}