summaryrefslogtreecommitdiffstats
path: root/sqlglot/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglot/__init__.py')
-rw-r--r--sqlglot/__init__.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/sqlglot/__init__.py b/sqlglot/__init__.py
index 04c3195..87fa081 100644
--- a/sqlglot/__init__.py
+++ b/sqlglot/__init__.py
@@ -32,7 +32,7 @@ from sqlglot.parser import Parser
from sqlglot.schema import MappingSchema
from sqlglot.tokens import Tokenizer, TokenType
-__version__ = "10.4.2"
+__version__ = "10.5.2"
pretty = False
@@ -60,9 +60,9 @@ def parse(
def parse_one(
sql: str,
read: t.Optional[str | Dialect] = None,
- into: t.Optional[Expression | str] = None,
+ into: t.Optional[t.Type[Expression] | str] = None,
**opts,
-) -> t.Optional[Expression]:
+) -> Expression:
"""
Parses the given SQL string and returns a syntax tree for the first parsed SQL statement.
@@ -83,7 +83,12 @@ def parse_one(
else:
result = dialect.parse(sql, **opts)
- return result[0] if result else None
+ for expression in result:
+ if not expression:
+ raise ParseError(f"No expression was parsed from '{sql}'")
+ return expression
+ else:
+ raise ParseError(f"No expression was parsed from '{sql}'")
def transpile(