toniphan21 commented on code in PR #28357:
URL: https://github.com/apache/superset/pull/28357#discussion_r1591407883
##########
superset/sql_parse.py:
##########
@@ -1582,7 +1582,7 @@ def extract_tables_from_jinja_sql(sql: str, database:
Database) -> set[Table]:
return (
tables
| ParsedQuery(
- sql_statement=processor.process_template(template),
Review Comment:
Sorry for the confusion (I updated the description). From the code, I
understand that this function will get tables from both ways. However, the
problem lies in
[ParsedQuery.stripped()](https://github.com/apache/superset/blob/2a7bfa4bb3735e5f72ddd104c1dbb989af2dcaf1/superset/sql_parse.py#L987-L988),
which is supposed to strip whitespace characters out of the given `sql`. If
you pass `nodes.Template`, it will throw an exception because there is no
`strip()` method in `nodes.Template`.
Please correct me if I'm wrong, but I understand that in the first part, you
already "Extract any tables referenced within the confines of specific Jinja
macros." Then, in this part, the given `sql` should be processed via the
`processor` to create a raw `sql_statement`, which is then put into the
`ParsedQuery` class to extract `tables`. If that is the purpose, hence the
variable passed to `processor.process_template(...)` should be a given SQL,
which may include Jinja macros.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]