Skip to content

Commit

Permalink
more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvergnaud committed Oct 2, 2024
1 parent be59a8f commit 9b35060
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/databricks/labs/ucx/source_code/sql/sql_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def find_all(self, klass: type[E]) -> Iterator[E]:

class SqlParser:

@staticmethod
def walk_expressions(sql_code: str, callback: Callable[[SqlExpression], Iterable[T]]) -> Iterable[T]:
@classmethod
def walk_expressions(cls, sql_code: str, callback: Callable[[SqlExpression], Iterable[T]]) -> Iterable[T]:
try:
expressions = parse(sql_code, read='databricks')
for expression in expressions:
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/source_code/sql/test_sql_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest
from sqlglot import ParseError

from databricks.labs.ucx.source_code.sql.sql_parser import SqlParser


def test_raises_exception_with_unsupported_sql():
with pytest.raises(ParseError):
list(SqlParser.walk_expressions("XSELECT * from nowhere", lambda _: []))

0 comments on commit 9b35060

Please sign in to comment.