Federated queries in SnowFlake?

1.1k Views Asked by At

I have three organizations which want to collaborate. All three of them have the same backend database and tables, and want to run a federated query across these three tables. Is that possible using snowflake?

2

There are 2 best solutions below

0
Simeon Pilgrim On

If they each have one "table" each, and data share it to the other two, that can have the three "tables" and

SELECT a.*, b.*, c.*
FROM mytable AS a
JOIN their_table_one AS b
JOIN the_other_table AS c

just fine.

0
Michael Golos On

You can import all tables into Snowflake and then create views that combine these tables so that they are visible as one view.

Example:

CREATE VIEW Table1_v
AS
SELECT col1, col2, col3, 'Source A' AS src
  FROM SourceA_Table1
 UNION ALL
SELECT col1, col2, col3, 'Source B' AS src
  FROM SourceB_Table1
 UNION ALL
SELECT col1, col2, col3, 'Source C' AS src
  FROM SourceC_Table1;