-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors when embedding Presto inside of Python strings #278
Comments
I do a similar thing but with Ruby e.g. sql = <<~SQL
SELECT *
FROM table
WHERE id = %{id}
SQL unfortunately there isn't a good way to make the parser recover gracefully since it's not actually valid SQL syntax. Tree-sitter should recover most of the time and not make things look completely broken but I have the occasional query where that's not the case. |
Makes sense! Due to the compilation steps of |
I think you'd have to fork the repo to extend the parser in that way. It's like not too hard, you could just add the curly brace ( Line 3484 in c649cb9
|
I was wondering if it would not be possible to have recursive injections. I mean nvim-treesitter knows that the embedded code is SQL, so why not apply the query for injections there as well. |
Almost all of the SQL I write is inside of python data pipelines, using Spark and Presto flavoured syntax.
So my queries are written like
When using
tree-sitter-sql
via neovim, I extended it to also capture the content inside of these strings via an injection.This "works", using
:InspectTree
I can see it correctly captures SELECT/WITH statement, but once it gets to the python string interpolationFROM {THREAD_TABLE}
, the parser errors.This is quite a crazy use-case, but wondered if there is anything that can be done to make the parser looser in this context so it at least does not error out?
The text was updated successfully, but these errors were encountered: