summaryrefslogtreecommitdiffstats
path: root/sqlglot/__init__.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:48:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:48:11 +0000
commit379c6d1f52e1d311867c4f789dc389da1d9af898 (patch)
treec9ca62eb7b8b7e861cc67248850db220ad0881c9 /sqlglot/__init__.py
parentReleasing debian version 17.7.0-1. (diff)
downloadsqlglot-379c6d1f52e1d311867c4f789dc389da1d9af898.tar.xz
sqlglot-379c6d1f52e1d311867c4f789dc389da1d9af898.zip
Merging upstream version 17.9.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/__init__.py')
-rw-r--r--sqlglot/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/sqlglot/__init__.py b/sqlglot/__init__.py
index 42801ac..be10f3d 100644
--- a/sqlglot/__init__.py
+++ b/sqlglot/__init__.py
@@ -67,19 +67,22 @@ schema = MappingSchema()
"""The default schema used by SQLGlot (e.g. in the optimizer)."""
-def parse(sql: str, read: DialectType = None, **opts) -> t.List[t.Optional[Expression]]:
+def parse(
+ sql: str, read: DialectType = None, dialect: DialectType = None, **opts
+) -> t.List[t.Optional[Expression]]:
"""
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).
**opts: other `sqlglot.parser.Parser` options.
Returns:
The resulting syntax tree collection.
"""
- dialect = Dialect.get_or_raise(read)()
+ dialect = Dialect.get_or_raise(read or dialect)()
return dialect.parse(sql, **opts)