Edit on GitHub

sqlglot.dialects.dremio

 1from __future__ import annotations
 2
 3from sqlglot import tokens
 4from sqlglot.dialects.dialect import Dialect
 5from sqlglot.generators.dremio import DremioGenerator
 6from sqlglot.parsers.dremio import DremioParser
 7
 8
 9class Dremio(Dialect):
10    SUPPORTS_USER_DEFINED_TYPES = False
11    CONCAT_COALESCE = True
12    CONCAT_WS_COALESCE = True
13    TYPED_DIVISION = True
14    NULL_ORDERING = "nulls_are_last"
15    SUPPORTS_VALUES_DEFAULT = False
16
17    TIME_MAPPING = {
18        # year
19        "YYYY": "%Y",
20        "yyyy": "%Y",
21        "YY": "%y",
22        "yy": "%y",
23        # month / day
24        "MM": "%m",
25        "mm": "%m",
26        "MON": "%b",
27        "mon": "%b",
28        "MONTH": "%B",
29        "month": "%B",
30        "DDD": "%j",
31        "ddd": "%j",
32        "DD": "%d",
33        "dd": "%d",
34        "DY": "%a",
35        "dy": "%a",
36        "DAY": "%A",
37        "day": "%A",
38        # hours / minutes / seconds
39        "HH24": "%H",
40        "hh24": "%H",
41        "HH12": "%I",
42        "hh12": "%I",
43        "HH": "%I",
44        "hh": "%I",  # 24- / 12-hour
45        "MI": "%M",
46        "mi": "%M",
47        "SS": "%S",
48        "ss": "%S",
49        "FFF": "%f",
50        "fff": "%f",
51        "AMPM": "%p",
52        "ampm": "%p",
53        # ISO week / century etc.
54        "WW": "%W",
55        "ww": "%W",
56        "D": "%w",
57        "d": "%w",
58        "CC": "%C",
59        "cc": "%C",
60        # timezone
61        "TZD": "%Z",
62        "tzd": "%Z",  # abbreviation (UTC, PST, ...)
63        "TZO": "%z",
64        "tzo": "%z",  # numeric offset (+0200)
65    }
66
67    class Tokenizer(tokens.Tokenizer):
68        COMMENTS = ["--", "//", ("/*", "*/")]
69
70    Parser = DremioParser
71
72    Generator = DremioGenerator
class Dremio(sqlglot.dialects.dialect.Dialect):
10class Dremio(Dialect):
11    SUPPORTS_USER_DEFINED_TYPES = False
12    CONCAT_COALESCE = True
13    CONCAT_WS_COALESCE = True
14    TYPED_DIVISION = True
15    NULL_ORDERING = "nulls_are_last"
16    SUPPORTS_VALUES_DEFAULT = False
17
18    TIME_MAPPING = {
19        # year
20        "YYYY": "%Y",
21        "yyyy": "%Y",
22        "YY": "%y",
23        "yy": "%y",
24        # month / day
25        "MM": "%m",
26        "mm": "%m",
27        "MON": "%b",
28        "mon": "%b",
29        "MONTH": "%B",
30        "month": "%B",
31        "DDD": "%j",
32        "ddd": "%j",
33        "DD": "%d",
34        "dd": "%d",
35        "DY": "%a",
36        "dy": "%a",
37        "DAY": "%A",
38        "day": "%A",
39        # hours / minutes / seconds
40        "HH24": "%H",
41        "hh24": "%H",
42        "HH12": "%I",
43        "hh12": "%I",
44        "HH": "%I",
45        "hh": "%I",  # 24- / 12-hour
46        "MI": "%M",
47        "mi": "%M",
48        "SS": "%S",
49        "ss": "%S",
50        "FFF": "%f",
51        "fff": "%f",
52        "AMPM": "%p",
53        "ampm": "%p",
54        # ISO week / century etc.
55        "WW": "%W",
56        "ww": "%W",
57        "D": "%w",
58        "d": "%w",
59        "CC": "%C",
60        "cc": "%C",
61        # timezone
62        "TZD": "%Z",
63        "tzd": "%Z",  # abbreviation (UTC, PST, ...)
64        "TZO": "%z",
65        "tzo": "%z",  # numeric offset (+0200)
66    }
67
68    class Tokenizer(tokens.Tokenizer):
69        COMMENTS = ["--", "//", ("/*", "*/")]
70
71    Parser = DremioParser
72
73    Generator = DremioGenerator
SUPPORTS_USER_DEFINED_TYPES = False

Whether user-defined data types are supported.

CONCAT_COALESCE = True

A NULL arg in CONCAT yields NULL by default, but in some dialects it yields an empty string.

CONCAT_WS_COALESCE = True

A NULL arg in CONCAT_WS yields NULL by default, but in some dialects it is skipped.

TYPED_DIVISION = True

Whether the behavior of a / b depends on the types of a and b. False means a / b is always float division. True means a / b is integer division if both a and b are integers.

NULL_ORDERING = 'nulls_are_last'

Default NULL ordering method to use if not explicitly set. Possible values: "nulls_are_small", "nulls_are_large", "nulls_are_last"

SUPPORTS_VALUES_DEFAULT = False

Whether the DEFAULT keyword is supported in the VALUES clause.

TIME_MAPPING: dict[str, str] = {'YYYY': '%Y', 'yyyy': '%Y', 'YY': '%y', 'yy': '%y', 'MM': '%m', 'mm': '%m', 'MON': '%b', 'mon': '%b', 'MONTH': '%B', 'month': '%B', 'DDD': '%j', 'ddd': '%j', 'DD': '%d', 'dd': '%d', 'DY': '%a', 'dy': '%a', 'DAY': '%A', 'day': '%A', 'HH24': '%H', 'hh24': '%H', 'HH12': '%I', 'hh12': '%I', 'HH': '%I', 'hh': '%I', 'MI': '%M', 'mi': '%M', 'SS': '%S', 'ss': '%S', 'FFF': '%f', 'fff': '%f', 'AMPM': '%p', 'ampm': '%p', 'WW': '%W', 'ww': '%W', 'D': '%w', 'd': '%w', 'CC': '%C', 'cc': '%C', 'TZD': '%Z', 'tzd': '%Z', 'TZO': '%z', 'tzo': '%z'}

Associates this dialect's time formats with their equivalent Python strftime formats.

SUPPORTS_COLUMN_JOIN_MARKS = False

Whether the old-style outer join (+) syntax is supported.

STRINGS_SUPPORT_ESCAPED_SEQUENCES: bool = False

Whether string literals support escape sequences (e.g. \n). Set by the metaclass based on the tokenizer's STRING_ESCAPES.

BYTE_STRINGS_SUPPORT_ESCAPED_SEQUENCES: bool = False

Whether byte string literals support escape sequences. Set by the metaclass based on the tokenizer's BYTE_STRING_ESCAPES.

INITCAP_SUPPORTS_CUSTOM_DELIMITERS = False
tokenizer_class = <class 'Dremio.Tokenizer'>
jsonpath_tokenizer_class = <class 'sqlglot.dialects.dialect.JSONPathTokenizer'>
parser_class = <class 'sqlglot.parsers.dremio.DremioParser'>
generator_class = <class 'sqlglot.generators.dremio.DremioGenerator'>
TIME_TRIE: dict = {'Y': {'Y': {'Y': {'Y': {0: True}}, 0: True}}, 'y': {'y': {'y': {'y': {0: True}}, 0: True}}, 'M': {'M': {0: True}, 'O': {'N': {0: True, 'T': {'H': {0: True}}}}, 'I': {0: True}}, 'm': {'m': {0: True}, 'o': {'n': {0: True, 't': {'h': {0: True}}}}, 'i': {0: True}}, 'D': {'D': {'D': {0: True}, 0: True}, 'Y': {0: True}, 'A': {'Y': {0: True}}, 0: True}, 'd': {'d': {'d': {0: True}, 0: True}, 'y': {0: True}, 'a': {'y': {0: True}}, 0: True}, 'H': {'H': {'2': {'4': {0: True}}, '1': {'2': {0: True}}, 0: True}}, 'h': {'h': {'2': {'4': {0: True}}, '1': {'2': {0: True}}, 0: True}}, 'S': {'S': {0: True}}, 's': {'s': {0: True}}, 'F': {'F': {'F': {0: True}}}, 'f': {'f': {'f': {0: True}}}, 'A': {'M': {'P': {'M': {0: True}}}}, 'a': {'m': {'p': {'m': {0: True}}}}, 'W': {'W': {0: True}}, 'w': {'w': {0: True}}, 'C': {'C': {0: True}}, 'c': {'c': {0: True}}, 'T': {'Z': {'D': {0: True}, 'O': {0: True}}}, 't': {'z': {'d': {0: True}, 'o': {0: True}}}}
FORMAT_TRIE: dict = {'Y': {'Y': {'Y': {'Y': {0: True}}, 0: True}}, 'y': {'y': {'y': {'y': {0: True}}, 0: True}}, 'M': {'M': {0: True}, 'O': {'N': {0: True, 'T': {'H': {0: True}}}}, 'I': {0: True}}, 'm': {'m': {0: True}, 'o': {'n': {0: True, 't': {'h': {0: True}}}}, 'i': {0: True}}, 'D': {'D': {'D': {0: True}, 0: True}, 'Y': {0: True}, 'A': {'Y': {0: True}}, 0: True}, 'd': {'d': {'d': {0: True}, 0: True}, 'y': {0: True}, 'a': {'y': {0: True}}, 0: True}, 'H': {'H': {'2': {'4': {0: True}}, '1': {'2': {0: True}}, 0: True}}, 'h': {'h': {'2': {'4': {0: True}}, '1': {'2': {0: True}}, 0: True}}, 'S': {'S': {0: True}}, 's': {'s': {0: True}}, 'F': {'F': {'F': {0: True}}}, 'f': {'f': {'f': {0: True}}}, 'A': {'M': {'P': {'M': {0: True}}}}, 'a': {'m': {'p': {'m': {0: True}}}}, 'W': {'W': {0: True}}, 'w': {'w': {0: True}}, 'C': {'C': {0: True}}, 'c': {'c': {0: True}}, 'T': {'Z': {'D': {0: True}, 'O': {0: True}}}, 't': {'z': {'d': {0: True}, 'o': {0: True}}}}
INVERSE_TIME_MAPPING: dict[str, str] = {'%Y': 'yyyy', '%y': 'yy', '%m': 'mm', '%b': 'mon', '%B': 'month', '%j': 'ddd', '%d': 'dd', '%a': 'dy', '%A': 'day', '%H': 'hh24', '%I': 'hh', '%M': 'mi', '%S': 'ss', '%f': 'fff', '%p': 'ampm', '%W': 'ww', '%w': 'd', '%C': 'cc', '%Z': 'tzd', '%z': 'tzo'}
INVERSE_TIME_TRIE: dict = {'%': {'Y': {0: True}, 'y': {0: True}, 'm': {0: True}, 'b': {0: True}, 'B': {0: True}, 'j': {0: True}, 'd': {0: True}, 'a': {0: True}, 'A': {0: True}, 'H': {0: True}, 'I': {0: True}, 'M': {0: True}, 'S': {0: True}, 'f': {0: True}, 'p': {0: True}, 'W': {0: True}, 'w': {0: True}, 'C': {0: True}, 'Z': {0: True}, 'z': {0: True}}}
INVERSE_FORMAT_MAPPING: dict[str, str] = {}
INVERSE_FORMAT_TRIE: dict = {}
INVERSE_CREATABLE_KIND_MAPPING: dict[str, str] = {}
ESCAPED_SEQUENCES: dict[str, str] = {}
QUOTE_START = "'"
QUOTE_END = "'"
IDENTIFIER_START = '"'
IDENTIFIER_END = '"'
VALID_INTERVAL_UNITS: set[str] = {'DAYOFYEAR', 'H', 'MICROSEC', 'NSECONDS', 'S', 'MONTHS', 'DEC', 'EPOCH_SECOND', 'WEEKOFYEAR', 'CENTS', 'DW', 'QUARTERS', 'WEEKDAY_ISO', 'DECADE', 'NANOSEC', 'CENTURY', 'EPOCH', 'MSECS', 'M', 'DAYOFWEEK', 'WEEKDAY', 'CENTURIES', 'MILS', 'MI', 'DAYOFWEEKISO', 'MONTH', 'HOURS', 'DOW_ISO', 'WEEK_ISO', 'SEC', 'NSECOND', 'DAY', 'HH', 'MSEC', 'EPOCH_MICROSECONDS', 'CENT', 'DAYOFWEEK_ISO', 'YYY', 'YEAR', 'USECOND', 'C', 'EPOCH_SECONDS', 'YR', 'MIN', 'NSEC', 'WY', 'USECS', 'WEEKOFYEAR_ISO', 'DAY OF YEAR', 'YEARS', 'NANOSECOND', 'QTR', 'DOW', 'WEEKISO', 'EPOCH_MICROSECOND', 'DY', 'MILLISEC', 'MM', 'W', 'WEEK', 'SECONDS', 'NANOSECS', 'MILLISECON', 'SECOND', 'USECONDS', 'D', 'US', 'EPOCH_NANOSECONDS', 'Y', 'NS', 'EPOCH_NANOSECOND', 'YYYY', 'DW_ISO', 'DAYOFMONTH', 'QUARTER', 'MON', 'Q', 'MIL', 'MONS', 'WOY', 'WEEKOFYEARISO', 'MINUTE', 'YY', 'USEC', 'YRS', 'MILLISECONDS', 'MILLENNIUM', 'TIMEZONE_MINUTE', 'HR', 'HOUR', 'MICROSECONDS', 'EPOCH_MILLISECONDS', 'MILLISECOND', 'MILLISECS', 'MINS', 'MSECOND', 'WK', 'MSECONDS', 'DD', 'TIMEZONE_HOUR', 'TZM', 'MICROSECOND', 'MINUTES', 'DECS', 'QTRS', 'MS', 'TZH', 'MICROSECS', 'EPOCH_MILLISECOND', 'DECADES', 'HRS', 'DAY OF WEEK', 'SECS', 'DAYS', 'DOY', 'MILLENIA'}
BIT_START: str | None = None
BIT_END: str | None = None
HEX_START: str | None = None
HEX_END: str | None = None
BYTE_START: str | None = None
BYTE_END: str | None = None
UNICODE_START: str | None = None
UNICODE_END: str | None = None
class Dremio.Tokenizer(sqlglot.tokens.Tokenizer):
68    class Tokenizer(tokens.Tokenizer):
69        COMMENTS = ["--", "//", ("/*", "*/")]
COMMENTS = ['--', '//', ('/*', '*/')]
BYTE_STRING_ESCAPES: ClassVar[list[str]] = ["'"]