From d2e9401b18925b5702c5c758af7d4f5b61deb493 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 May 2023 08:44:54 +0200 Subject: Adding upstream version 12.2.0. Signed-off-by: Daniel Baumann --- docs/sqlglot.html | 467 +++++++++++++++++++++++++++--------------------------- 1 file changed, 235 insertions(+), 232 deletions(-) (limited to 'docs/sqlglot.html') diff --git a/docs/sqlglot.html b/docs/sqlglot.html index 8c37b8d..1bbf2ae 100644 --- a/docs/sqlglot.html +++ b/docs/sqlglot.html @@ -673,168 +673,171 @@ 21 Expression as Expression, 22 alias_ as alias, 23 and_ as and_, - 24 column as column, - 25 condition as condition, - 26 except_ as except_, - 27 from_ as from_, - 28 intersect as intersect, - 29 maybe_parse as maybe_parse, - 30 not_ as not_, - 31 or_ as or_, - 32 select as select, - 33 subquery as subquery, - 34 table_ as table, - 35 to_column as to_column, - 36 to_table as to_table, - 37 union as union, - 38) - 39from sqlglot.generator import Generator as Generator - 40from sqlglot.parser import Parser as Parser - 41from sqlglot.schema import MappingSchema as MappingSchema, Schema as Schema - 42from sqlglot.tokens import Tokenizer as Tokenizer, TokenType as TokenType - 43 - 44if t.TYPE_CHECKING: - 45 from sqlglot.dialects.dialect import DialectType as DialectType + 24 cast as cast, + 25 column as column, + 26 condition as condition, + 27 except_ as except_, + 28 from_ as from_, + 29 func as func, + 30 intersect as intersect, + 31 maybe_parse as maybe_parse, + 32 not_ as not_, + 33 or_ as or_, + 34 select as select, + 35 subquery as subquery, + 36 table_ as table, + 37 to_column as to_column, + 38 to_identifier as to_identifier, + 39 to_table as to_table, + 40 union as union, + 41) + 42from sqlglot.generator import Generator as Generator + 43from sqlglot.parser import Parser as Parser + 44from sqlglot.schema import MappingSchema as MappingSchema, Schema as Schema + 45from sqlglot.tokens import Tokenizer as Tokenizer, TokenType as TokenType 46 - 47 T = t.TypeVar("T", bound=Expression) - 48 + 47if t.TYPE_CHECKING: + 48 from sqlglot.dialects.dialect import DialectType as DialectType 49 - 50__version__ = "11.6.3" + 50 T = t.TypeVar("T", bound=Expression) 51 - 52pretty = False - 53"""Whether to format generated SQL by default.""" + 52 + 53__version__ = "12.1.0" 54 - 55schema = MappingSchema() - 56"""The default schema used by SQLGlot (e.g. in the optimizer).""" + 55pretty = False + 56"""Whether to format generated SQL by default.""" 57 - 58 - 59def parse(sql: str, read: DialectType = None, **opts) -> t.List[t.Optional[Expression]]: - 60 """ - 61 Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement. - 62 - 63 Args: - 64 sql: the SQL code string to parse. - 65 read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql"). - 66 **opts: other `sqlglot.parser.Parser` options. - 67 - 68 Returns: - 69 The resulting syntax tree collection. - 70 """ - 71 dialect = Dialect.get_or_raise(read)() - 72 return dialect.parse(sql, **opts) - 73 - 74 - 75@t.overload - 76def parse_one( - 77 sql: str, - 78 read: None = None, - 79 into: t.Type[T] = ..., - 80 **opts, - 81) -> T: - 82 ... - 83 - 84 - 85@t.overload - 86def parse_one( - 87 sql: str, - 88 read: DialectType, - 89 into: t.Type[T], - 90 **opts, - 91) -> T: - 92 ... - 93 - 94 - 95@t.overload - 96def parse_one( - 97 sql: str, - 98 read: None = None, - 99 into: t.Union[str, t.Collection[t.Union[str, t.Type[Expression]]]] = ..., -100 **opts, -101) -> Expression: -102 ... -103 -104 -105@t.overload -106def parse_one( -107 sql: str, -108 read: DialectType, -109 into: t.Union[str, t.Collection[t.Union[str, t.Type[Expression]]]], -110 **opts, -111) -> Expression: -112 ... -113 -114 -115@t.overload -116def parse_one( -117 sql: str, -118 **opts, -119) -> Expression: -120 ... -121 -122 -123def parse_one( -124 sql: str, -125 read: DialectType = None, -126 into: t.Optional[exp.IntoType] = None, -127 **opts, -128) -> Expression: -129 """ -130 Parses the given SQL string and returns a syntax tree for the first parsed SQL statement. -131 -132 Args: -133 sql: the SQL code string to parse. -134 read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql"). -135 into: the SQLGlot Expression to parse into. -136 **opts: other `sqlglot.parser.Parser` options. -137 -138 Returns: -139 The syntax tree for the first parsed statement. -140 """ -141 -142 dialect = Dialect.get_or_raise(read)() -143 -144 if into: -145 result = dialect.parse_into(into, sql, **opts) -146 else: -147 result = dialect.parse(sql, **opts) -148 -149 for expression in result: -150 if not expression: -151 raise ParseError(f"No expression was parsed from '{sql}'") -152 return expression -153 else: -154 raise ParseError(f"No expression was parsed from '{sql}'") -155 -156 -157def transpile( -158 sql: str, -159 read: DialectType = None, -160 write: DialectType = None, -161 identity: bool = True, -162 error_level: t.Optional[ErrorLevel] = None, -163 **opts, -164) -> t.List[str]: -165 """ -166 Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed -167 to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement. -168 -169 Args: -170 sql: the SQL code string to transpile. -171 read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql"). -172 write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql"). -173 identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both: -174 the source and the target dialect. -175 error_level: the desired error level of the parser. -176 **opts: other `sqlglot.generator.Generator` options. -177 -178 Returns: -179 The list of transpiled SQL statements. -180 """ -181 write = write or read if identity else write -182 return [ -183 Dialect.get_or_raise(write)().generate(expression, **opts) -184 for expression in parse(sql, read, error_level=error_level) -185 ] + 58schema = MappingSchema() + 59"""The default schema used by SQLGlot (e.g. in the optimizer).""" + 60 + 61 + 62def parse(sql: str, read: DialectType = None, **opts) -> t.List[t.Optional[Expression]]: + 63 """ + 64 Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement. + 65 + 66 Args: + 67 sql: the SQL code string to parse. + 68 read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql"). + 69 **opts: other `sqlglot.parser.Parser` options. + 70 + 71 Returns: + 72 The resulting syntax tree collection. + 73 """ + 74 dialect = Dialect.get_or_raise(read)() + 75 return dialect.parse(sql, **opts) + 76 + 77 + 78@t.overload + 79def parse_one( + 80 sql: str, + 81 read: None = None, + 82 into: t.Type[T] = ..., + 83 **opts, + 84) -> T: + 85 ... + 86 + 87 + 88@t.overload + 89def parse_one( + 90 sql: str, + 91 read: DialectType, + 92 into: t.Type[T], + 93 **opts, + 94) -> T: + 95 ... + 96 + 97 + 98@t.overload + 99def parse_one( +100 sql: str, +101 read: None = None, +102 into: t.Union[str, t.Collection[t.Union[str, t.Type[Expression]]]] = ..., +103 **opts, +104) -> Expression: +105 ... +106 +107 +108@t.overload +109def parse_one( +110 sql: str, +111 read: DialectType, +112 into: t.Union[str, t.Collection[t.Union[str, t.Type[Expression]]]], +113 **opts, +114) -> Expression: +115 ... +116 +117 +118@t.overload +119def parse_one( +120 sql: str, +121 **opts, +122) -> Expression: +123 ... +124 +125 +126def parse_one( +127 sql: str, +128 read: DialectType = None, +129 into: t.Optional[exp.IntoType] = None, +130 **opts, +131) -> Expression: +132 """ +133 Parses the given SQL string and returns a syntax tree for the first parsed SQL statement. +134 +135 Args: +136 sql: the SQL code string to parse. +137 read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql"). +138 into: the SQLGlot Expression to parse into. +139 **opts: other `sqlglot.parser.Parser` options. +140 +141 Returns: +142 The syntax tree for the first parsed statement. +143 """ +144 +145 dialect = Dialect.get_or_raise(read)() +146 +147 if into: +148 result = dialect.parse_into(into, sql, **opts) +149 else: +150 result = dialect.parse(sql, **opts) +151 +152 for expression in result: +153 if not expression: +154 raise ParseError(f"No expression was parsed from '{sql}'") +155 return expression +156 else: +157 raise ParseError(f"No expression was parsed from '{sql}'") +158 +159 +160def transpile( +161 sql: str, +162 read: DialectType = None, +163 write: DialectType = None, +164 identity: bool = True, +165 error_level: t.Optional[ErrorLevel] = None, +166 **opts, +167) -> t.List[str]: +168 """ +169 Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed +170 to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement. +171 +172 Args: +173 sql: the SQL code string to transpile. +174 read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql"). +175 write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql"). +176 identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both: +177 the source and the target dialect. +178 error_level: the desired error level of the parser. +179 **opts: other `sqlglot.generator.Generator` options. +180 +181 Returns: +182 The list of transpiled SQL statements. +183 """ +184 write = write or read if identity else write +185 return [ +186 Dialect.get_or_raise(write)().generate(expression, **opts) +187 for expression in parse(sql, read, error_level=error_level) +188 ] @@ -878,20 +881,20 @@ -
60def parse(sql: str, read: DialectType = None, **opts) -> t.List[t.Optional[Expression]]:
-61    """
-62    Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement.
-63
-64    Args:
-65        sql: the SQL code string to parse.
-66        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
-67        **opts: other `sqlglot.parser.Parser` options.
-68
-69    Returns:
-70        The resulting syntax tree collection.
-71    """
-72    dialect = Dialect.get_or_raise(read)()
-73    return dialect.parse(sql, **opts)
+            
63def parse(sql: str, read: DialectType = None, **opts) -> t.List[t.Optional[Expression]]:
+64    """
+65    Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement.
+66
+67    Args:
+68        sql: the SQL code string to parse.
+69        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
+70        **opts: other `sqlglot.parser.Parser` options.
+71
+72    Returns:
+73        The resulting syntax tree collection.
+74    """
+75    dialect = Dialect.get_or_raise(read)()
+76    return dialect.parse(sql, **opts)
 
@@ -925,38 +928,38 @@
-
124def parse_one(
-125    sql: str,
-126    read: DialectType = None,
-127    into: t.Optional[exp.IntoType] = None,
-128    **opts,
-129) -> Expression:
-130    """
-131    Parses the given SQL string and returns a syntax tree for the first parsed SQL statement.
-132
-133    Args:
-134        sql: the SQL code string to parse.
-135        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
-136        into: the SQLGlot Expression to parse into.
-137        **opts: other `sqlglot.parser.Parser` options.
-138
-139    Returns:
-140        The syntax tree for the first parsed statement.
-141    """
-142
-143    dialect = Dialect.get_or_raise(read)()
-144
-145    if into:
-146        result = dialect.parse_into(into, sql, **opts)
-147    else:
-148        result = dialect.parse(sql, **opts)
-149
-150    for expression in result:
-151        if not expression:
-152            raise ParseError(f"No expression was parsed from '{sql}'")
-153        return expression
-154    else:
-155        raise ParseError(f"No expression was parsed from '{sql}'")
+            
127def parse_one(
+128    sql: str,
+129    read: DialectType = None,
+130    into: t.Optional[exp.IntoType] = None,
+131    **opts,
+132) -> Expression:
+133    """
+134    Parses the given SQL string and returns a syntax tree for the first parsed SQL statement.
+135
+136    Args:
+137        sql: the SQL code string to parse.
+138        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
+139        into: the SQLGlot Expression to parse into.
+140        **opts: other `sqlglot.parser.Parser` options.
+141
+142    Returns:
+143        The syntax tree for the first parsed statement.
+144    """
+145
+146    dialect = Dialect.get_or_raise(read)()
+147
+148    if into:
+149        result = dialect.parse_into(into, sql, **opts)
+150    else:
+151        result = dialect.parse(sql, **opts)
+152
+153    for expression in result:
+154        if not expression:
+155            raise ParseError(f"No expression was parsed from '{sql}'")
+156        return expression
+157    else:
+158        raise ParseError(f"No expression was parsed from '{sql}'")
 
@@ -991,35 +994,35 @@
-
158def transpile(
-159    sql: str,
-160    read: DialectType = None,
-161    write: DialectType = None,
-162    identity: bool = True,
-163    error_level: t.Optional[ErrorLevel] = None,
-164    **opts,
-165) -> t.List[str]:
-166    """
-167    Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed
-168    to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement.
-169
-170    Args:
-171        sql: the SQL code string to transpile.
-172        read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql").
-173        write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql").
-174        identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both:
-175            the source and the target dialect.
-176        error_level: the desired error level of the parser.
-177        **opts: other `sqlglot.generator.Generator` options.
-178
-179    Returns:
-180        The list of transpiled SQL statements.
-181    """
-182    write = write or read if identity else write
-183    return [
-184        Dialect.get_or_raise(write)().generate(expression, **opts)
-185        for expression in parse(sql, read, error_level=error_level)
-186    ]
+            
161def transpile(
+162    sql: str,
+163    read: DialectType = None,
+164    write: DialectType = None,
+165    identity: bool = True,
+166    error_level: t.Optional[ErrorLevel] = None,
+167    **opts,
+168) -> t.List[str]:
+169    """
+170    Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed
+171    to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement.
+172
+173    Args:
+174        sql: the SQL code string to transpile.
+175        read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql").
+176        write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql").
+177        identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both:
+178            the source and the target dialect.
+179        error_level: the desired error level of the parser.
+180        **opts: other `sqlglot.generator.Generator` options.
+181
+182    Returns:
+183        The list of transpiled SQL statements.
+184    """
+185    write = write or read if identity else write
+186    return [
+187        Dialect.get_or_raise(write)().generate(expression, **opts)
+188        for expression in parse(sql, read, error_level=error_level)
+189    ]
 
-- cgit v1.2.3