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,
439        "null_if_no_match": False,
440        "empty_if_group_missing": False,
441    }
442
443
444class RegexpExtractAll(Expression, Func):
445    arg_types = {
446        "this": True,
447        "expression": True,
448        "group": False,
449        "parameters": False,
450        "position": False,
451        "occurrence": False,
452    }
453
454
455class RegexpFullMatch(Expression, Binary, Predicate, Func):
456    arg_types = {"this": True, "expression": True, "options": False}
457
458
459class RegexpILike(Expression, Binary, Predicate, Func):
460    arg_types = {"this": True, "expression": True, "flag": False}
461
462
463class RegexpInstr(Expression, Func):
464    arg_types = {
465        "this": True,
466        "expression": True,
467        "position": False,
468        "occurrence": False,
469        "option": False,
470        "parameters": False,
471        "group": False,
472    }
473
474
475class RegexpReplace(Expression, Func):
476    arg_types = {
477        "this": True,
478        "expression": True,
479        "replacement": False,
480        "position": False,
481        "occurrence": False,
482        "modifiers": False,
483        "single_replace": False,
484    }
485
486
487class RegexpSplit(Expression, Func):
488    # "mode" is Dremio-specific, appended after "limit" for from_arg_list compat
489    arg_types = {"this": True, "expression": True, "limit": False, "mode": False}
490
491
492class RegexpSubstr(Expression, Func):
493    arg_types = {
494        "this": True,
495        "expression": True,
496        "position": False,
497        "occurrence": False,
498        "parameters": False,
499        "group": False,
500    }
501
502
503# Hashing / cryptographic
504
505
506class Compress(Expression, Func):
507    arg_types = {"this": True, "method": False}
508
509
510class Decrypt(Expression, Func):
511    arg_types = {
512        "this": True,
513        "passphrase": True,
514        "aad": False,
515        "encryption_method": False,
516        "safe": False,
517    }
518
519
520class DecryptRaw(Expression, Func):
521    arg_types = {
522        "this": True,
523        "key": True,
524        "iv": True,
525        "aad": False,
526        "encryption_method": False,
527        "aead": False,
528        "safe": False,
529    }
530
531
532class DecompressBinary(Expression, Func):
533    arg_types = {"this": True, "method": True}
534
535
536class DecompressString(Expression, Func):
537    arg_types = {"this": True, "method": True}
538
539
540class Encrypt(Expression, Func):
541    arg_types = {"this": True, "passphrase": True, "aad": False, "encryption_method": False}
542
543
544class EncryptRaw(Expression, Func):
545    arg_types = {"this": True, "key": True, "iv": True, "aad": False, "encryption_method": False}
546
547
548class CityHash64(Expression, Func):
549    arg_types = {"expressions": False}
550    is_var_len_args = True
551
552
553class FarmFingerprint(Expression, Func):
554    arg_types = {"expressions": True}
555    is_var_len_args = True
556    _sql_names = ["FARM_FINGERPRINT", "FARMFINGERPRINT64"]
557
558
559class MD5(Expression, Func):
560    _sql_names = ["MD5"]
561
562
563class MD5Digest(Expression, Func):
564    arg_types = {"this": True, "expressions": False}
565    is_var_len_args = True
566    _sql_names = ["MD5_DIGEST"]
567
568
569class MD5NumberLower64(Expression, Func):
570    pass
571
572
573class MD5NumberUpper64(Expression, Func):
574    pass
575
576
577class SHA(Expression, Func):
578    _sql_names = ["SHA", "SHA1"]
579
580
581class SHA1Digest(Expression, Func):
582    pass
583
584
585class SHA2(Expression, Func):
586    _sql_names = ["SHA2"]
587    arg_types = {"this": True, "length": False}
588
589
590class SHA2Digest(Expression, Func):
591    arg_types = {"this": True, "length": False}
592
593
594class StandardHash(Expression, Func):
595    arg_types = {"this": True, "expression": False}
596
597
598# Parse
599
600
601class ParseBignumeric(Expression, Func):
602    pass
603
604
605class ParseNumeric(Expression, Func):
606    pass
607
608
609class ParseUrl(Expression, Func):
610    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]]' = {'this', 'expression'}
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]]' = {'this', 'expression'}
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]]' = {'this', 'expression'}
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]]' = {'this', 'format'}
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]]' = {'this', 'expression', '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]]' = {'this', 'expression', 'is_left'}
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]]' = {'this', 'times'}
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]]' = {'this', 'expression'}
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]]' = {'this', 'expression'}
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]]' = {'this', 'expression'}
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]]' = {'this', 'expression'}
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]]' = {'this', 'expression'}
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', 'this', 'start', '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]]' = {'this', 'to', '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]]' = {'charset', 'this'}
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]]' = {'charset', 'this'}
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]]' = {'this', 'expression'}
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]]' = {'this', 'expression'}
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,
440        "null_if_no_match": False,
441        "empty_if_group_missing": False,
442    }
arg_types = {'this': True, 'expression': True, 'position': False, 'occurrence': False, 'parameters': False, 'group': False, 'null_if_pos_overflow': False, 'null_if_no_match': False, 'empty_if_group_missing': False}
key: ClassVar[str] = 'regexpextract'
required_args: 't.ClassVar[set[str]]' = {'this', 'expression'}
445class RegexpExtractAll(Expression, Func):
446    arg_types = {
447        "this": True,
448        "expression": True,
449        "group": False,
450        "parameters": False,
451        "position": False,
452        "occurrence": False,
453    }
arg_types = {'this': True, 'expression': True, 'group': False, 'parameters': False, 'position': False, 'occurrence': False}
key: ClassVar[str] = 'regexpextractall'
required_args: 't.ClassVar[set[str]]' = {'this', 'expression'}
456class RegexpFullMatch(Expression, Binary, Predicate, Func):
457    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]]' = {'this', 'expression'}
460class RegexpILike(Expression, Binary, Predicate, Func):
461    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]]' = {'this', 'expression'}
464class RegexpInstr(Expression, Func):
465    arg_types = {
466        "this": True,
467        "expression": True,
468        "position": False,
469        "occurrence": False,
470        "option": False,
471        "parameters": False,
472        "group": False,
473    }
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]]' = {'this', 'expression'}
476class RegexpReplace(Expression, Func):
477    arg_types = {
478        "this": True,
479        "expression": True,
480        "replacement": False,
481        "position": False,
482        "occurrence": False,
483        "modifiers": False,
484        "single_replace": False,
485    }
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]]' = {'this', 'expression'}
488class RegexpSplit(Expression, Func):
489    # "mode" is Dremio-specific, appended after "limit" for from_arg_list compat
490    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]]' = {'this', 'expression'}
493class RegexpSubstr(Expression, Func):
494    arg_types = {
495        "this": True,
496        "expression": True,
497        "position": False,
498        "occurrence": False,
499        "parameters": False,
500        "group": False,
501    }
arg_types = {'this': True, 'expression': True, 'position': False, 'occurrence': False, 'parameters': False, 'group': False}
key: ClassVar[str] = 'regexpsubstr'
required_args: 't.ClassVar[set[str]]' = {'this', 'expression'}
507class Compress(Expression, Func):
508    arg_types = {"this": True, "method": False}
arg_types = {'this': True, 'method': False}
key: ClassVar[str] = 'compress'
required_args: 't.ClassVar[set[str]]' = {'this'}
511class Decrypt(Expression, Func):
512    arg_types = {
513        "this": True,
514        "passphrase": True,
515        "aad": False,
516        "encryption_method": False,
517        "safe": False,
518    }
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'}
521class DecryptRaw(Expression, Func):
522    arg_types = {
523        "this": True,
524        "key": True,
525        "iv": True,
526        "aad": False,
527        "encryption_method": False,
528        "aead": False,
529        "safe": False,
530    }
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', 'this', 'key'}
533class DecompressBinary(Expression, Func):
534    arg_types = {"this": True, "method": True}
arg_types = {'this': True, 'method': True}
key: ClassVar[str] = 'decompressbinary'
required_args: 't.ClassVar[set[str]]' = {'this', 'method'}
537class DecompressString(Expression, Func):
538    arg_types = {"this": True, "method": True}
arg_types = {'this': True, 'method': True}
key: ClassVar[str] = 'decompressstring'
required_args: 't.ClassVar[set[str]]' = {'this', 'method'}
541class Encrypt(Expression, Func):
542    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'}
545class EncryptRaw(Expression, Func):
546    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', 'this', 'key'}
549class CityHash64(Expression, Func):
550    arg_types = {"expressions": False}
551    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()
554class FarmFingerprint(Expression, Func):
555    arg_types = {"expressions": True}
556    is_var_len_args = True
557    _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'}
560class MD5(Expression, Func):
561    _sql_names = ["MD5"]
key: ClassVar[str] = 'md5'
required_args: 't.ClassVar[set[str]]' = {'this'}
564class MD5Digest(Expression, Func):
565    arg_types = {"this": True, "expressions": False}
566    is_var_len_args = True
567    _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'}
570class MD5NumberLower64(Expression, Func):
571    pass
key: ClassVar[str] = 'md5numberlower64'
required_args: 't.ClassVar[set[str]]' = {'this'}
574class MD5NumberUpper64(Expression, Func):
575    pass
key: ClassVar[str] = 'md5numberupper64'
required_args: 't.ClassVar[set[str]]' = {'this'}
578class SHA(Expression, Func):
579    _sql_names = ["SHA", "SHA1"]
key: ClassVar[str] = 'sha'
required_args: 't.ClassVar[set[str]]' = {'this'}
582class SHA1Digest(Expression, Func):
583    pass
key: ClassVar[str] = 'sha1digest'
required_args: 't.ClassVar[set[str]]' = {'this'}
586class SHA2(Expression, Func):
587    _sql_names = ["SHA2"]
588    arg_types = {"this": True, "length": False}
arg_types = {'this': True, 'length': False}
key: ClassVar[str] = 'sha2'
required_args: 't.ClassVar[set[str]]' = {'this'}
591class SHA2Digest(Expression, Func):
592    arg_types = {"this": True, "length": False}
arg_types = {'this': True, 'length': False}
key: ClassVar[str] = 'sha2digest'
required_args: 't.ClassVar[set[str]]' = {'this'}
595class StandardHash(Expression, Func):
596    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'standardhash'
required_args: 't.ClassVar[set[str]]' = {'this'}
602class ParseBignumeric(Expression, Func):
603    pass
key: ClassVar[str] = 'parsebignumeric'
required_args: 't.ClassVar[set[str]]' = {'this'}
606class ParseNumeric(Expression, Func):
607    pass
key: ClassVar[str] = 'parsenumeric'
required_args: 't.ClassVar[set[str]]' = {'this'}
610class ParseUrl(Expression, Func):
611    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'}