Reputation: 83
How can I create an query on an existing query? I tried multiple versions.
SELECT * FROM {{q_....}}
does not works
Upvotes: 2
Views: 647
Reputation: 601
This query pattern doesn't exist in Slate. You can use Partials to reuse parts of query logic across multiple queries or formulate your query logic in a function, but you can't "query" the results of an existing query.
Postgres will use some caching strategies automatically so that if you're running similar queries in succession you'll see some improved performance.
Upvotes: 0
Reputation: 171
For security reasons, templated values in SQL queries must be wrapped in special helpers.
In the example above, you would need to use the schema
and table
helpers to ensure that only pre-approved table names are templated in. This prevents accidental (or malicious) access to undesired tables.
For example something like:
SELECT column1 FROM {{schema someSchemaName 'allowedSchemaName1' 'allowedSchemaName2'}}.{{table someTableName 'allowedTableName1'}};
Please see the official docs for more details on this.
Upvotes: 0