bito-code-review[bot] commented on PR #42785:
URL: https://github.com/apache/superset/pull/42785#issuecomment-5187401687
<!-- Bito Reply -->
The issue is that `kinds > {"data"}` requires the lexer to return at least
one token that is *not* a `data` token (e.g., `variable_begin`, `block_begin`).
However, if the SQL contains only `data` tokens (which happens for plain SQL)
or if the Jinja lexer identifies tokens differently for certain templates, the
condition might fail incorrectly.
To resolve this, you should check if there are any tokens other than `data`
tokens. A more robust approach is to check if the set of tokens contains
anything besides `data`:
```python
return any(kind != "data" for _, kind, _ in self.env.lex(sql))
```
This change ensures that if any token is found that is not classified as
`data`, the function correctly identifies the presence of a template.
**superset/jinja_context.py**
```
return any(kind != "data" for _, kind, _ in self.env.lex(sql))
```
--
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]