feat: use sqlglot to validate adhoc subquery (#33560)

This commit is contained in:
Beto Dealmeida
2025-05-30 18:09:19 -04:00
committed by GitHub
parent cf315388f2
commit 401ce56fa1
10 changed files with 123 additions and 92 deletions

View File

@@ -462,6 +462,14 @@ class BaseSQLStatement(Generic[InternalRepresentation]):
"""
raise NotImplementedError()
def has_subquery(self) -> bool:
"""
Check if the statement has a subquery.
:return: True if the statement has a subquery at the top level.
"""
raise NotImplementedError()
def parse_predicate(self, predicate: str) -> InternalRepresentation:
"""
Parse a predicate string into an AST.
@@ -803,6 +811,14 @@ class SQLStatement(BaseSQLStatement[exp.Expression]):
return SQLStatement(ast=create_table, engine=self.engine)
def has_subquery(self) -> bool:
"""
Check if the statement has a subquery.
:return: True if the statement has a subquery at the top level.
"""
return bool(self._parsed.find(exp.Subquery))
def parse_predicate(self, predicate: str) -> exp.Expression:
"""
Parse a predicate string into an AST.