mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat: use sqlglot to validate adhoc subquery (#33560)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user