From aedf35026379f52d7e2b4c1f957691410a758089 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 8 Feb 2024 06:38:39 +0100 Subject: Adding upstream version 21.0.1. Signed-off-by: Daniel Baumann --- docs/sqlglot.html | 475 +++++++++++++++++++++++++++--------------------------- 1 file changed, 238 insertions(+), 237 deletions(-) (limited to 'docs/sqlglot.html') diff --git a/docs/sqlglot.html b/docs/sqlglot.html index 80c82d9..a64c853 100644 --- a/docs/sqlglot.html +++ b/docs/sqlglot.html @@ -707,170 +707,171 @@ make check # Full test suite & linter checks -
  1"""
-  2.. include:: ../README.md
-  3
-  4----
-  5"""
-  6
-  7from __future__ import annotations
-  8
-  9import logging
- 10import typing as t
- 11
- 12from sqlglot import expressions as exp
- 13from sqlglot.dialects.dialect import Dialect as Dialect, Dialects as Dialects
- 14from sqlglot.diff import diff as diff
- 15from sqlglot.errors import (
- 16    ErrorLevel as ErrorLevel,
- 17    ParseError as ParseError,
- 18    TokenError as TokenError,
- 19    UnsupportedError as UnsupportedError,
- 20)
- 21from sqlglot.expressions import (
- 22    Expression as Expression,
- 23    alias_ as alias,
- 24    and_ as and_,
- 25    case as case,
- 26    cast as cast,
- 27    column as column,
- 28    condition as condition,
- 29    except_ as except_,
- 30    from_ as from_,
- 31    func as func,
- 32    intersect as intersect,
- 33    maybe_parse as maybe_parse,
- 34    not_ as not_,
- 35    or_ as or_,
- 36    select as select,
- 37    subquery as subquery,
- 38    table_ as table,
- 39    to_column as to_column,
- 40    to_identifier as to_identifier,
- 41    to_table as to_table,
- 42    union as union,
- 43)
- 44from sqlglot.generator import Generator as Generator
- 45from sqlglot.parser import Parser as Parser
- 46from sqlglot.schema import MappingSchema as MappingSchema, Schema as Schema
- 47from sqlglot.tokens import Tokenizer as Tokenizer, TokenType as TokenType
- 48
- 49if t.TYPE_CHECKING:
- 50    from sqlglot._typing import E
- 51    from sqlglot.dialects.dialect import DialectType as DialectType
- 52
- 53logger = logging.getLogger("sqlglot")
- 54
+                        
  1# ruff: noqa: F401
+  2"""
+  3.. include:: ../README.md
+  4
+  5----
+  6"""
+  7
+  8from __future__ import annotations
+  9
+ 10import logging
+ 11import typing as t
+ 12
+ 13from sqlglot import expressions as exp
+ 14from sqlglot.dialects.dialect import Dialect as Dialect, Dialects as Dialects
+ 15from sqlglot.diff import diff as diff
+ 16from sqlglot.errors import (
+ 17    ErrorLevel as ErrorLevel,
+ 18    ParseError as ParseError,
+ 19    TokenError as TokenError,
+ 20    UnsupportedError as UnsupportedError,
+ 21)
+ 22from sqlglot.expressions import (
+ 23    Expression as Expression,
+ 24    alias_ as alias,
+ 25    and_ as and_,
+ 26    case as case,
+ 27    cast as cast,
+ 28    column as column,
+ 29    condition as condition,
+ 30    except_ as except_,
+ 31    from_ as from_,
+ 32    func as func,
+ 33    intersect as intersect,
+ 34    maybe_parse as maybe_parse,
+ 35    not_ as not_,
+ 36    or_ as or_,
+ 37    select as select,
+ 38    subquery as subquery,
+ 39    table_ as table,
+ 40    to_column as to_column,
+ 41    to_identifier as to_identifier,
+ 42    to_table as to_table,
+ 43    union as union,
+ 44)
+ 45from sqlglot.generator import Generator as Generator
+ 46from sqlglot.parser import Parser as Parser
+ 47from sqlglot.schema import MappingSchema as MappingSchema, Schema as Schema
+ 48from sqlglot.tokens import Tokenizer as Tokenizer, TokenType as TokenType
+ 49
+ 50if t.TYPE_CHECKING:
+ 51    from sqlglot._typing import E
+ 52    from sqlglot.dialects.dialect import DialectType as DialectType
+ 53
+ 54logger = logging.getLogger("sqlglot")
  55
- 56try:
- 57    from sqlglot._version import __version__, __version_tuple__
- 58except ImportError:
- 59    logger.error(
- 60        "Unable to set __version__, run `pip install -e .` or `python setup.py develop` first."
- 61    )
- 62
+ 56
+ 57try:
+ 58    from sqlglot._version import __version__, __version_tuple__
+ 59except ImportError:
+ 60    logger.error(
+ 61        "Unable to set __version__, run `pip install -e .` or `python setup.py develop` first."
+ 62    )
  63
- 64pretty = False
- 65"""Whether to format generated SQL by default."""
- 66
- 67schema = MappingSchema()
- 68"""The default schema used by SQLGlot (e.g. in the optimizer)."""
- 69
+ 64
+ 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
- 71def parse(
- 72    sql: str, read: DialectType = None, dialect: DialectType = None, **opts
- 73) -> t.List[t.Optional[Expression]]:
- 74    """
- 75    Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement.
- 76
- 77    Args:
- 78        sql: the SQL code string to parse.
- 79        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
- 80        dialect: the SQL dialect (alias for read).
- 81        **opts: other `sqlglot.parser.Parser` options.
- 82
- 83    Returns:
- 84        The resulting syntax tree collection.
- 85    """
- 86    return Dialect.get_or_raise(read or dialect).parse(sql, **opts)
- 87
+ 71
+ 72def parse(
+ 73    sql: str, read: DialectType = None, dialect: DialectType = None, **opts
+ 74) -> t.List[t.Optional[Expression]]:
+ 75    """
+ 76    Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement.
+ 77
+ 78    Args:
+ 79        sql: the SQL code string to parse.
+ 80        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
+ 81        dialect: the SQL dialect (alias for read).
+ 82        **opts: other `sqlglot.parser.Parser` options.
+ 83
+ 84    Returns:
+ 85        The resulting syntax tree collection.
+ 86    """
+ 87    return Dialect.get_or_raise(read or dialect).parse(sql, **opts)
  88
- 89@t.overload
- 90def parse_one(sql: str, *, into: t.Type[E], **opts) -> E:
- 91    ...
- 92
+ 89
+ 90@t.overload
+ 91def parse_one(sql: str, *, into: t.Type[E], **opts) -> E:
+ 92    ...
  93
- 94@t.overload
- 95def parse_one(sql: str, **opts) -> Expression:
- 96    ...
- 97
+ 94
+ 95@t.overload
+ 96def parse_one(sql: str, **opts) -> Expression:
+ 97    ...
  98
- 99def parse_one(
-100    sql: str,
-101    read: DialectType = None,
-102    dialect: DialectType = None,
-103    into: t.Optional[exp.IntoType] = None,
-104    **opts,
-105) -> Expression:
-106    """
-107    Parses the given SQL string and returns a syntax tree for the first parsed SQL statement.
-108
-109    Args:
-110        sql: the SQL code string to parse.
-111        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
-112        dialect: the SQL dialect (alias for read)
-113        into: the SQLGlot Expression to parse into.
-114        **opts: other `sqlglot.parser.Parser` options.
-115
-116    Returns:
-117        The syntax tree for the first parsed statement.
-118    """
-119
-120    dialect = Dialect.get_or_raise(read or dialect)
-121
-122    if into:
-123        result = dialect.parse_into(into, sql, **opts)
-124    else:
-125        result = dialect.parse(sql, **opts)
-126
-127    for expression in result:
-128        if not expression:
-129            raise ParseError(f"No expression was parsed from '{sql}'")
-130        return expression
-131    else:
-132        raise ParseError(f"No expression was parsed from '{sql}'")
-133
+ 99
+100def parse_one(
+101    sql: str,
+102    read: DialectType = None,
+103    dialect: DialectType = None,
+104    into: t.Optional[exp.IntoType] = None,
+105    **opts,
+106) -> Expression:
+107    """
+108    Parses the given SQL string and returns a syntax tree for the first parsed SQL statement.
+109
+110    Args:
+111        sql: the SQL code string to parse.
+112        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
+113        dialect: the SQL dialect (alias for read)
+114        into: the SQLGlot Expression to parse into.
+115        **opts: other `sqlglot.parser.Parser` options.
+116
+117    Returns:
+118        The syntax tree for the first parsed statement.
+119    """
+120
+121    dialect = Dialect.get_or_raise(read or dialect)
+122
+123    if into:
+124        result = dialect.parse_into(into, sql, **opts)
+125    else:
+126        result = dialect.parse(sql, **opts)
+127
+128    for expression in result:
+129        if not expression:
+130            raise ParseError(f"No expression was parsed from '{sql}'")
+131        return expression
+132    else:
+133        raise ParseError(f"No expression was parsed from '{sql}'")
 134
-135def transpile(
-136    sql: str,
-137    read: DialectType = None,
-138    write: DialectType = None,
-139    identity: bool = True,
-140    error_level: t.Optional[ErrorLevel] = None,
-141    **opts,
-142) -> t.List[str]:
-143    """
-144    Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed
-145    to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement.
-146
-147    Args:
-148        sql: the SQL code string to transpile.
-149        read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql").
-150        write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql").
-151        identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both:
-152            the source and the target dialect.
-153        error_level: the desired error level of the parser.
-154        **opts: other `sqlglot.generator.Generator` options.
-155
-156    Returns:
-157        The list of transpiled SQL statements.
-158    """
-159    write = (read if write is None else write) if identity else write
-160    write = Dialect.get_or_raise(write)
-161    return [
-162        write.generate(expression, copy=False, **opts) if expression else ""
-163        for expression in parse(sql, read, error_level=error_level)
-164    ]
+135
+136def transpile(
+137    sql: str,
+138    read: DialectType = None,
+139    write: DialectType = None,
+140    identity: bool = True,
+141    error_level: t.Optional[ErrorLevel] = None,
+142    **opts,
+143) -> t.List[str]:
+144    """
+145    Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed
+146    to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement.
+147
+148    Args:
+149        sql: the SQL code string to transpile.
+150        read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql").
+151        write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql").
+152        identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both:
+153            the source and the target dialect.
+154        error_level: the desired error level of the parser.
+155        **opts: other `sqlglot.generator.Generator` options.
+156
+157    Returns:
+158        The list of transpiled SQL statements.
+159    """
+160    write = (read if write is None else write) if identity else write
+161    write = Dialect.get_or_raise(write)
+162    return [
+163        write.generate(expression, copy=False, **opts) if expression else ""
+164        for expression in parse(sql, read, error_level=error_level)
+165    ]
 
@@ -926,22 +927,22 @@ make check # Full test suite & linter checks
-
72def parse(
-73    sql: str, read: DialectType = None, dialect: DialectType = None, **opts
-74) -> t.List[t.Optional[Expression]]:
-75    """
-76    Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement.
-77
-78    Args:
-79        sql: the SQL code string to parse.
-80        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
-81        dialect: the SQL dialect (alias for read).
-82        **opts: other `sqlglot.parser.Parser` options.
-83
-84    Returns:
-85        The resulting syntax tree collection.
-86    """
-87    return Dialect.get_or_raise(read or dialect).parse(sql, **opts)
+            
73def parse(
+74    sql: str, read: DialectType = None, dialect: DialectType = None, **opts
+75) -> t.List[t.Optional[Expression]]:
+76    """
+77    Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement.
+78
+79    Args:
+80        sql: the SQL code string to parse.
+81        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
+82        dialect: the SQL dialect (alias for read).
+83        **opts: other `sqlglot.parser.Parser` options.
+84
+85    Returns:
+86        The resulting syntax tree collection.
+87    """
+88    return Dialect.get_or_raise(read or dialect).parse(sql, **opts)
 
@@ -976,40 +977,40 @@ make check # Full test suite & linter checks
-
100def parse_one(
-101    sql: str,
-102    read: DialectType = None,
-103    dialect: DialectType = None,
-104    into: t.Optional[exp.IntoType] = None,
-105    **opts,
-106) -> Expression:
-107    """
-108    Parses the given SQL string and returns a syntax tree for the first parsed SQL statement.
-109
-110    Args:
-111        sql: the SQL code string to parse.
-112        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
-113        dialect: the SQL dialect (alias for read)
-114        into: the SQLGlot Expression to parse into.
-115        **opts: other `sqlglot.parser.Parser` options.
-116
-117    Returns:
-118        The syntax tree for the first parsed statement.
-119    """
-120
-121    dialect = Dialect.get_or_raise(read or dialect)
-122
-123    if into:
-124        result = dialect.parse_into(into, sql, **opts)
-125    else:
-126        result = dialect.parse(sql, **opts)
-127
-128    for expression in result:
-129        if not expression:
-130            raise ParseError(f"No expression was parsed from '{sql}'")
-131        return expression
-132    else:
-133        raise ParseError(f"No expression was parsed from '{sql}'")
+            
101def parse_one(
+102    sql: str,
+103    read: DialectType = None,
+104    dialect: DialectType = None,
+105    into: t.Optional[exp.IntoType] = None,
+106    **opts,
+107) -> Expression:
+108    """
+109    Parses the given SQL string and returns a syntax tree for the first parsed SQL statement.
+110
+111    Args:
+112        sql: the SQL code string to parse.
+113        read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
+114        dialect: the SQL dialect (alias for read)
+115        into: the SQLGlot Expression to parse into.
+116        **opts: other `sqlglot.parser.Parser` options.
+117
+118    Returns:
+119        The syntax tree for the first parsed statement.
+120    """
+121
+122    dialect = Dialect.get_or_raise(read or dialect)
+123
+124    if into:
+125        result = dialect.parse_into(into, sql, **opts)
+126    else:
+127        result = dialect.parse(sql, **opts)
+128
+129    for expression in result:
+130        if not expression:
+131            raise ParseError(f"No expression was parsed from '{sql}'")
+132        return expression
+133    else:
+134        raise ParseError(f"No expression was parsed from '{sql}'")
 
@@ -1045,36 +1046,36 @@ make check # Full test suite & linter checks
-
136def transpile(
-137    sql: str,
-138    read: DialectType = None,
-139    write: DialectType = None,
-140    identity: bool = True,
-141    error_level: t.Optional[ErrorLevel] = None,
-142    **opts,
-143) -> t.List[str]:
-144    """
-145    Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed
-146    to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement.
-147
-148    Args:
-149        sql: the SQL code string to transpile.
-150        read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql").
-151        write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql").
-152        identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both:
-153            the source and the target dialect.
-154        error_level: the desired error level of the parser.
-155        **opts: other `sqlglot.generator.Generator` options.
-156
-157    Returns:
-158        The list of transpiled SQL statements.
-159    """
-160    write = (read if write is None else write) if identity else write
-161    write = Dialect.get_or_raise(write)
-162    return [
-163        write.generate(expression, copy=False, **opts) if expression else ""
-164        for expression in parse(sql, read, error_level=error_level)
-165    ]
+            
137def transpile(
+138    sql: str,
+139    read: DialectType = None,
+140    write: DialectType = None,
+141    identity: bool = True,
+142    error_level: t.Optional[ErrorLevel] = None,
+143    **opts,
+144) -> t.List[str]:
+145    """
+146    Parses the given SQL string in accordance with the source dialect and returns a list of SQL strings transformed
+147    to conform to the target dialect. Each string in the returned list represents a single transformed SQL statement.
+148
+149    Args:
+150        sql: the SQL code string to transpile.
+151        read: the source dialect used to parse the input string (eg. "spark", "hive", "presto", "mysql").
+152        write: the target dialect into which the input should be transformed (eg. "spark", "hive", "presto", "mysql").
+153        identity: if set to `True` and if the target dialect is not specified the source dialect will be used as both:
+154            the source and the target dialect.
+155        error_level: the desired error level of the parser.
+156        **opts: other `sqlglot.generator.Generator` options.
+157
+158    Returns:
+159        The list of transpiled SQL statements.
+160    """
+161    write = (read if write is None else write) if identity else write
+162    write = Dialect.get_or_raise(write)
+163    return [
+164        write.generate(expression, copy=False, **opts) if expression else ""
+165        for expression in parse(sql, read, error_level=error_level)
+166    ]
 
-- cgit v1.2.3