Remote Subqueries
Remote subqueries enable the use of prepared data on a remote server, which is beneficial for complex queries or sensitive data protection.
Static Subqueries
In its most basic form, you can map a query on the remote server into a foreign table in Postgres. For instance:
1 2 3 4 5 6 7 8 9 |
|
In this example, the foreign table clickhouse.people
data is read from the result of the subquery select * from people where age < 25
which runs on ClickHouse server.
Dynamic Subqueries
What if the query is not fixed and needs to be dynamic? For example, ClickHouse provides Parameterized Views which can accept parameters for a view. Wrappers supports this by defining a column for each parameter.
Let's take a look at an example:
1 2 3 4 5 6 7 8 9 10 11 |
|
You can then pass values to these parameters in your query:
1 2 3 |
|
Currently, this feature is supported by ClickHouse FDW and BigQuery FDW, with plans to expand support in the future.