I am working in deepnote, and since I cannot alter my table (How do I rename a column in Dataframe SQL?) I wondered if there is a possibility to reuse a query in a new SQL block.
I know that every query can be saved as pandas DataFrame, and with the syntax {{ variable_name }}
variables can be reintroduced into DataFrame SQL.
However, after saving a previous SQL query as df
the code
SELECT *
FROM {{ df }}
does unfortunately not work.
The error message I get is: "There is no Dataframe named ? in scope!"
What am I missing here?
FYI: Deepnote's DataFrame SQL is based on JinjaSQL, if that helps in any way.
Deepnote allows you to reference dataframe variables directly as table names in SQL. So you should be able to do:
SELECT *
FROM df
instead of using the JinjaSQL syntax.
Example: https://deepnote.com/@the21st/Querying-dataframes-with-SQL-4ac53104-9b0e-4f7b-897c-2ddbe0923d34