feat(sqlparse): improve table parsing (#26476)

(cherry picked from commit c0b57bd1c3)
This commit is contained in:
Beto Dealmeida
2024-01-22 11:16:50 -05:00
committed by Michael S. Molina
parent 6cdaf479f2
commit 1d9cfdabd1
17 changed files with 265 additions and 120 deletions

View File

@@ -208,7 +208,7 @@ def execute_sql_statement( # pylint: disable=too-many-arguments, too-many-local
database: Database = query.database
db_engine_spec = database.db_engine_spec
parsed_query = ParsedQuery(sql_statement)
parsed_query = ParsedQuery(sql_statement, engine=db_engine_spec.engine)
if is_feature_enabled("RLS_IN_SQLLAB"):
# There are two ways to insert RLS: either replacing the table with a subquery
# that has the RLS, or appending the RLS to the ``WHERE`` clause. The former is
@@ -228,7 +228,8 @@ def execute_sql_statement( # pylint: disable=too-many-arguments, too-many-local
database.id,
query.schema,
)
)
),
engine=db_engine_spec.engine,
)
sql = parsed_query.stripped()
@@ -419,7 +420,11 @@ def execute_sql_statements(
)
# Breaking down into multiple statements
parsed_query = ParsedQuery(rendered_query, strip_comments=True)
parsed_query = ParsedQuery(
rendered_query,
strip_comments=True,
engine=db_engine_spec.engine,
)
if not db_engine_spec.run_multiple_statements_as_one:
statements = parsed_query.get_statements()
logger.info(