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],
)
| 90 | |
| 91 | |
| 92 | def 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 |
no test coverage detected
searching dependent graphs…