MCPcopy Create free account
hub / github.com/tobymao/sqlglot / parse

Function parse

sqlglot/__init__.py:92–110  ·  view source on GitHub ↗

Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement. Args: sql: the SQL code string to parse. read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql"). dialect: the SQL dialect (alias for read).

(
    sql: str,
    read: DialectType = None,
    dialect: DialectType = None,
    **opts: Unpack[ParserNoDialectArgs],
)

Source from the content-addressed store, hash-verified

90
91
92def parse(
93 sql: str,
94 read: DialectType = None,
95 dialect: DialectType = None,
96 **opts: Unpack[ParserNoDialectArgs],
97) -> list[Expr | None]:
98 """
99 Parses the given SQL string into a collection of syntax trees, one per parsed SQL statement.
100
101 Args:
102 sql: the SQL code string to parse.
103 read: the SQL dialect to apply during parsing (eg. "spark", "hive", "presto", "mysql").
104 dialect: the SQL dialect (alias for read).
105 **opts: other `sqlglot.parser.Parser` options.
106
107 Returns:
108 The resulting syntax tree collection.
109 """
110 return Dialect.get_or_raise(read or dialect).parse(sql, **opts)
111
112
113@t.overload

Callers 1

transpileFunction · 0.70

Calls 2

get_or_raiseMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…