From 278f416d08028bd175e1d6433739461f2168f4e2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 11 Jun 2024 18:34:56 +0200 Subject: Adding upstream version 25.0.3. Signed-off-by: Daniel Baumann --- docs/sqlglot.html | 418 ++++++++++++++++++++++++++---------------------------- 1 file changed, 199 insertions(+), 219 deletions(-) (limited to 'docs/sqlglot.html') diff --git a/docs/sqlglot.html b/docs/sqlglot.html index 75ca255..34c331b 100644 --- a/docs/sqlglot.html +++ b/docs/sqlglot.html @@ -67,9 +67,6 @@
  • pretty
  • -
  • - schema -
  • tokenize
  • @@ -809,117 +806,114 @@ make check # Full test suite & linter checks 65pretty = False 66"""Whether to format generated SQL by default.""" 67 - 68schema = MappingSchema() - 69"""The default schema used by SQLGlot (e.g. in the optimizer).""" - 70 - 71 - 72def tokenize(sql: str, read: DialectType = None, dialect: DialectType = None) -> t.List[Token]: - 73 """ - 74 Tokenizes the given SQL string. - 75 - 76 Args: - 77 sql: the SQL code string to tokenize. - 78 read: the SQL dialect to apply during tokenizing (eg. "spark", "hive", "presto", "mysql"). - 79 dialect: the SQL dialect (alias for read). - 80 - 81 Returns: - 82 The resulting list of tokens. - 83 """ - 84 return Dialect.get_or_raise(read or dialect).tokenize(sql) - 85 - 86 - 87def parse( - 88 sql: str, read: DialectType = None, dialect: DialectType = None, **opts - 89) -> t.List[t.Optional[Expression]]: - 90 """ - 91 Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement. - 92 - 93 Args: - 94 sql: the SQL code string to parse. - 95 read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql"). - 96 dialect: the SQL dialect (alias for read). - 97 **opts: other `sqlglot.parser.Parser` options. - 98 - 99 Returns: -100 The resulting syntax tree collection. -101 """ -102 return Dialect.get_or_raise(read or dialect).parse(sql, **opts) -103 + 68 + 69def tokenize(sql: str, read: DialectType = None, dialect: DialectType = None) -> t.List[Token]: + 70 """ + 71 Tokenizes the given SQL string. + 72 + 73 Args: + 74 sql: the SQL code string to tokenize. + 75 read: the SQL dialect to apply during tokenizing (eg. "spark", "hive", "presto", "mysql"). + 76 dialect: the SQL dialect (alias for read). + 77 + 78 Returns: + 79 The resulting list of tokens. + 80 """ + 81 return Dialect.get_or_raise(read or dialect).tokenize(sql) + 82 + 83 + 84def parse( + 85 sql: str, read: DialectType = None, dialect: DialectType = None, **opts + 86) -> t.List[t.Optional[Expression]]: + 87 """ + 88 Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement. + 89 + 90 Args: + 91 sql: the SQL code string to parse. + 92 read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql"). + 93 dialect: the SQL dialect (alias for read). + 94 **opts: other `sqlglot.parser.Parser` options. + 95 + 96 Returns: + 97 The resulting syntax tree collection. + 98 """ + 99 return Dialect.get_or_raise(read or dialect).parse(sql, **opts) +100 +101 +102@t.overload +103def parse_one(sql: str, *, into: t.Type[E], **opts) -> E: ... 104 -105@t.overload -106def parse_one(sql: str, *, into: t.Type[E], **opts) -> E: ... -107 +105 +106@t.overload +107def parse_one(sql: str, **opts) -> Expression: ... 108 -109@t.overload -110def parse_one(sql: str, **opts) -> Expression: ... -111 -112 -113def parse_one( -114 sql: str, -115 read: DialectType = None, -116 dialect: DialectType = None, -117 into: t.Optional[exp.IntoType] = None, -118 **opts, -119) -> Expression: -120 """ -121 Parses the given SQL string and returns a syntax tree for the first parsed SQL statement. -122 -123 Args: -124 sql: the SQL code string to parse. -125 read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql"). -126 dialect: the SQL dialect (alias for read) -127 into: the SQLGlot Expression to parse into. -128 **opts: other `sqlglot.parser.Parser` options. -129 -130 Returns: -131 The syntax tree for the first parsed statement. -132 """ -133 -134 dialect = Dialect.get_or_raise(read or dialect) -135 -136 if into: -137 result = dialect.parse_into(into, sql, **opts) -138 else: -139 result = dialect.parse(sql, **opts) -140 -141 for expression in result: -142 if not expression: -143 raise ParseError(f"No expression was parsed from '{sql}'") -144 return expression -145 else: -146 raise ParseError(f"No expression was parsed from '{sql}'") -147 -148 -149def transpile( -150 sql: str, -151 read: DialectType = None, -152 write: DialectType = None, -153 identity: bool = True, -154 error_level: t.Optional[ErrorLevel] = None, -155 **opts, -156) -> t.List[str]: -157 """ -158 Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed -159 to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement. -160 -161 Args: -162 sql: the SQL code string to transpile. -163 read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql"). -164 write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql"). -165 identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both: -166 the source and the target dialect. -167 error_level: the desired error level of the parser. -168 **opts: other `sqlglot.generator.Generator` options. -169 -170 Returns: -171 The list of transpiled SQL statements. -172 """ -173 write = (read if write is None else write) if identity else write -174 write = Dialect.get_or_raise(write) -175 return [ -176 write.generate(expression, copy=False, **opts) if expression else "" -177 for expression in parse(sql, read, error_level=error_level) -178 ] +109 +110def parse_one( +111 sql: str, +112 read: DialectType = None, +113 dialect: DialectType = None, +114 into: t.Optional[exp.IntoType] = None, +115 **opts, +116) -> Expression: +117 """ +118 Parses the given SQL string and returns a syntax tree for the first parsed SQL statement. +119 +120 Args: +121 sql: the SQL code string to parse. +122 read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql"). +123 dialect: the SQL dialect (alias for read) +124 into: the SQLGlot Expression to parse into. +125 **opts: other `sqlglot.parser.Parser` options. +126 +127 Returns: +128 The syntax tree for the first parsed statement. +129 """ +130 +131 dialect = Dialect.get_or_raise(read or dialect) +132 +133 if into: +134 result = dialect.parse_into(into, sql, **opts) +135 else: +136 result = dialect.parse(sql, **opts) +137 +138 for expression in result: +139 if not expression: +140 raise ParseError(f"No expression was parsed from '{sql}'") +141 return expression +142 else: +143 raise ParseError(f"No expression was parsed from '{sql}'") +144 +145 +146def transpile( +147 sql: str, +148 read: DialectType = None, +149 write: DialectType = None, +150 identity: bool = True, +151 error_level: t.Optional[ErrorLevel] = None, +152 **opts, +153) -> t.List[str]: +154 """ +155 Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed +156 to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement. +157 +158 Args: +159 sql: the SQL code string to transpile. +160 read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql"). +161 write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql"). +162 identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both: +163 the source and the target dialect. +164 error_level: the desired error level of the parser. +165 **opts: other `sqlglot.generator.Generator` options. +166 +167 Returns: +168 The list of transpiled SQL statements. +169 """ +170 write = (read if write is None else write) if identity else write +171 write = Dialect.get_or_raise(write) +172 return [ +173 write.generate(expression, copy=False, **opts) if expression else "" +174 for expression in parse(sql, read, error_level=error_level) +175 ] @@ -949,20 +943,6 @@ make check # Full test suite & linter checks - -
    -
    - schema = -<sqlglot.schema.MappingSchema object> - - -
    - - -

    The default schema used by SQLGlot (e.g. in the optimizer).

    -
    - -
    @@ -975,19 +955,19 @@ make check # Full test suite & linter checks -
    73def tokenize(sql: str, read: DialectType = None, dialect: DialectType = None) -> t.List[Token]:
    -74    """
    -75    Tokenizes the given SQL string.
    -76
    -77    Args:
    -78        sql: the SQL code string to tokenize.
    -79        read: the SQL dialect to apply during tokenizing (eg. "spark", "hive", "presto", "mysql").
    -80        dialect: the SQL dialect (alias for read).
    -81
    -82    Returns:
    -83        The resulting list of tokens.
    -84    """
    -85    return Dialect.get_or_raise(read or dialect).tokenize(sql)
    +            
    70def tokenize(sql: str, read: DialectType = None, dialect: DialectType = None) -> t.List[Token]:
    +71    """
    +72    Tokenizes the given SQL string.
    +73
    +74    Args:
    +75        sql: the SQL code string to tokenize.
    +76        read: the SQL dialect to apply during tokenizing (eg. "spark", "hive", "presto", "mysql").
    +77        dialect: the SQL dialect (alias for read).
    +78
    +79    Returns:
    +80        The resulting list of tokens.
    +81    """
    +82    return Dialect.get_or_raise(read or dialect).tokenize(sql)
     
    @@ -1021,22 +1001,22 @@ make check # Full test suite & linter checks
    -
     88def parse(
    - 89    sql: str, read: DialectType = None, dialect: DialectType = None, **opts
    - 90) -> t.List[t.Optional[Expression]]:
    - 91    """
    - 92    Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement.
    - 93
    - 94    Args:
    - 95        sql: the SQL code string to parse.
    - 96        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
    - 97        dialect: the SQL dialect (alias for read).
    - 98        **opts: other `sqlglot.parser.Parser` options.
    - 99
    -100    Returns:
    -101        The resulting syntax tree collection.
    -102    """
    -103    return Dialect.get_or_raise(read or dialect).parse(sql, **opts)
    +            
     85def parse(
    + 86    sql: str, read: DialectType = None, dialect: DialectType = None, **opts
    + 87) -> t.List[t.Optional[Expression]]:
    + 88    """
    + 89    Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement.
    + 90
    + 91    Args:
    + 92        sql: the SQL code string to parse.
    + 93        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
    + 94        dialect: the SQL dialect (alias for read).
    + 95        **opts: other `sqlglot.parser.Parser` options.
    + 96
    + 97    Returns:
    + 98        The resulting syntax tree collection.
    + 99    """
    +100    return Dialect.get_or_raise(read or dialect).parse(sql, **opts)
     
    @@ -1071,40 +1051,40 @@ make check # Full test suite & linter checks
    -
    114def parse_one(
    -115    sql: str,
    -116    read: DialectType = None,
    -117    dialect: DialectType = None,
    -118    into: t.Optional[exp.IntoType] = None,
    -119    **opts,
    -120) -> Expression:
    -121    """
    -122    Parses the given SQL string and returns a syntax tree for the first parsed SQL statement.
    -123
    -124    Args:
    -125        sql: the SQL code string to parse.
    -126        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
    -127        dialect: the SQL dialect (alias for read)
    -128        into: the SQLGlot Expression to parse into.
    -129        **opts: other `sqlglot.parser.Parser` options.
    -130
    -131    Returns:
    -132        The syntax tree for the first parsed statement.
    -133    """
    -134
    -135    dialect = Dialect.get_or_raise(read or dialect)
    -136
    -137    if into:
    -138        result = dialect.parse_into(into, sql, **opts)
    -139    else:
    -140        result = dialect.parse(sql, **opts)
    -141
    -142    for expression in result:
    -143        if not expression:
    -144            raise ParseError(f"No expression was parsed from '{sql}'")
    -145        return expression
    -146    else:
    -147        raise ParseError(f"No expression was parsed from '{sql}'")
    +            
    111def parse_one(
    +112    sql: str,
    +113    read: DialectType = None,
    +114    dialect: DialectType = None,
    +115    into: t.Optional[exp.IntoType] = None,
    +116    **opts,
    +117) -> Expression:
    +118    """
    +119    Parses the given SQL string and returns a syntax tree for the first parsed SQL statement.
    +120
    +121    Args:
    +122        sql: the SQL code string to parse.
    +123        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
    +124        dialect: the SQL dialect (alias for read)
    +125        into: the SQLGlot Expression to parse into.
    +126        **opts: other `sqlglot.parser.Parser` options.
    +127
    +128    Returns:
    +129        The syntax tree for the first parsed statement.
    +130    """
    +131
    +132    dialect = Dialect.get_or_raise(read or dialect)
    +133
    +134    if into:
    +135        result = dialect.parse_into(into, sql, **opts)
    +136    else:
    +137        result = dialect.parse(sql, **opts)
    +138
    +139    for expression in result:
    +140        if not expression:
    +141            raise ParseError(f"No expression was parsed from '{sql}'")
    +142        return expression
    +143    else:
    +144        raise ParseError(f"No expression was parsed from '{sql}'")
     
    @@ -1140,36 +1120,36 @@ make check # Full test suite & linter checks
    -
    150def transpile(
    -151    sql: str,
    -152    read: DialectType = None,
    -153    write: DialectType = None,
    -154    identity: bool = True,
    -155    error_level: t.Optional[ErrorLevel] = None,
    -156    **opts,
    -157) -> t.List[str]:
    -158    """
    -159    Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed
    -160    to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement.
    -161
    -162    Args:
    -163        sql: the SQL code string to transpile.
    -164        read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql").
    -165        write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql").
    -166        identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both:
    -167            the source and the target dialect.
    -168        error_level: the desired error level of the parser.
    -169        **opts: other `sqlglot.generator.Generator` options.
    -170
    -171    Returns:
    -172        The list of transpiled SQL statements.
    -173    """
    -174    write = (read if write is None else write) if identity else write
    -175    write = Dialect.get_or_raise(write)
    -176    return [
    -177        write.generate(expression, copy=False, **opts) if expression else ""
    -178        for expression in parse(sql, read, error_level=error_level)
    -179    ]
    +            
    147def transpile(
    +148    sql: str,
    +149    read: DialectType = None,
    +150    write: DialectType = None,
    +151    identity: bool = True,
    +152    error_level: t.Optional[ErrorLevel] = None,
    +153    **opts,
    +154) -> t.List[str]:
    +155    """
    +156    Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed
    +157    to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement.
    +158
    +159    Args:
    +160        sql: the SQL code string to transpile.
    +161        read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql").
    +162        write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql").
    +163        identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both:
    +164            the source and the target dialect.
    +165        error_level: the desired error level of the parser.
    +166        **opts: other `sqlglot.generator.Generator` options.
    +167
    +168    Returns:
    +169        The list of transpiled SQL statements.
    +170    """
    +171    write = (read if write is None else write) if identity else write
    +172    write = Dialect.get_or_raise(write)
    +173    return [
    +174        write.generate(expression, copy=False, **opts) if expression else ""
    +175        for expression in parse(sql, read, error_level=error_level)
    +176    ]
     
    -- cgit v1.2.3