Skip to main content

Connect a second Snowflake account

Copy a people directory from a second Snowflake account beside the first. You end with two context streams. Each has its own key, its own tables in Prism and its own label, and they run side by side.

This page covers the snowflake_snapshot recipe, which copies a table or view once a day. It assumes the first account is already connected by Copy a Snowflake table or view, steps 1 to 6. The second account needs the same things from its own administrator: a user, a key pair and a read-only role (that page's steps 1 and 2).

1. Register it with tables of its own​

The recipe copies into snowflake_snapshot_people, and two enabled sources may not fill the same table. A second copy therefore fills tables of its own, named <name>_<stream>. Registered as hr_directory, it fills hr_directory_people.

On the page. The recipe's tile stays open while the first copy is enabled, and says:

A second copy, from another account, needs tables of its own: tick "tables of its own" when you register it, and it fills <name>_<stream> beside the first.

If the first copy took the recipe's own name, the register form also says:

A source named snowflake_snapshot is already registered. Give this copy a name of its own; "tables of its own" is ticked for you.

The form then opens with no name and the tables of its own box ticked. Type the second copy's name and that account's five connection values, and clear the label box (step 3).

Over the API, the box is "tables": "own":

{"recipe": "snowflake_snapshot", "name": "hr_directory", "tables": "own",
"parameters": {"account": "…", "warehouse": "…", "database": "…",
"schema": "…", "user": "…"}}

Registered from the tile without editing the manifest, the source keeps its recipe: it runs in the recipe's engine lane, so the engine's per-recipe settings apply to it, and the self test's recipe drift line compares it with the recipe. Its stream fills hr_directory_people, and its dataset reads that table. A manifest edited in the register form is recorded as your own, with or without the box.

Under the recipe's own name, the box is refused:

under the recipe's own name, 'snowflake_snapshot', this source already fills the recipe's tables, so tables of its own would change nothing. Give it a name of its own.

A second copy registered without the box registers, but cannot be enabled while the first is registered, whether the first is on or switched off:

enabling 'sf_plain' would fill a datapond table that another registered source fills: snowflake_snapshot_people (filled by 'snowflake_snapshot', switched off). Its walk would treat that table as its own: its first run empties it, deleting the other's copies, or, if 'sf_plain' has run before, its copies mix with the other's. Switching a source off does not release its table. To go on: delete 'snowflake_snapshot' if 'sf_plain' is meant to replace it, or register 'sf_plain' again under a name of its own with "tables of its own" ticked ("tables": "own").

The two ways out:

  • To run both, delete the second copy and register it again, under the same name, with the box.
  • To replace the first, delete the first copy, then enable the second. The second's first run empties the table, so the first copy's history is not kept either way. Switching the first off is not enough: a registered source holds its table whether it is on or off, so that it can never be switched back on to mix its copies with the second's.

2. Give it that account's key​

Enter the second account's private key on the second source, as for the first (steps 2 and 5 of the Snowflake copy page). Each source keeps its own connection values and its own key. Each copy connects to its own account with its own key.

3. Check its label​

The label is what a reader is told a figure came from. A source registered under a name other than its recipe's, with no label given, is labelled <recipe label> (<name>). For hr_directory that is People directory (Snowflake copy) (hr_directory), beside the first copy's People directory (Snowflake copy). A label you give is used as it is. The register form fills its label box with the recipe's label, so on the page clear the box, or type a label of your own; otherwise the enable in step 4 is refused. Renaming the source moves the name in its label with it.

Two enabled sources may not carry the same label. Enabling one whose label another enabled source carries is refused, naming both:

enabling 'sf_third' would give two sources the same label, 'People directory (Snowflake copy)': 'snowflake_snapshot' already carries it. The label is what a reader is told a figure came from, so answers from the two could not be told apart. Give this source a label of its own (the manifest's policy.source_label) and try again. Nothing was written.

Labels that differ only in case or spacing count as the same. A built-in source (GitHub, Jira, GitLab) holds its label even while it is switched off.

4. Approve, enable, and let it land​

Probe, approve and enable it as for the first copy. Its first copy runs at the next ingest tick, and lands in its own table only: the first copy's table is not touched.

5. Keep field SQL on the source's own table​

The recipe's latest-copy filter, is_latest_snapshot, is (as_of = (SELECT MAX(as_of) FROM {{ table }})). {{ table }} is the table the dataset is read from, so on the second copy it reads hr_directory_people. Write {{ table }} wherever your own field or metric SQL needs the source's own table.

A literal table name that another enabled source fills is refused, whichever of the two you enable second:

enabling 'hr_directory' would leave 'hr_directory' reading snowflake_snapshot_people (/model/datasets/0/fields/7/sql), a table the enabled source 'snowflake_snapshot' fills, so its answers would be computed over the other source's rows. If that SQL names the table, write {{ table }} there for its own dataset's table; if it names a column, rename that column (its columns[].name) and the fields that read it. Nothing was written.

Registering or applying such a manifest while the other source is enabled is refused earlier, with the same remedy.

Switched-off and deleted copies count too. Switching a source off or deleting it does not remove its table, so field and metric SQL is also judged against the tables of every registered source that is not enabled, and of every recipe this build carries. A replacement copy pasted from the old copy's text is refused at register, apply and enable, naming the old copy as "(not enabled)" or naming "the 'snowflake_snapshot' recipe". A source already enabled before this was checked keeps running: the startup log and the self test's line for it say so, and it is refused the next time it is switched on. One case is not checked: a deleted source that had tables of its own leaves nothing that names its table. Use {{ table }}.

6. Choose which copy is the directory​

Only one source holds the organizational context stream: the directory every other source's people are resolved against. Designating the second copy while the first holds it is refused:

'snowflake_snapshot' already holds this installation's organizational context stream — the one directory of people every other source's rows are resolved against, and there may be only one enabled at a time. …

To make the second copy the directory instead, press Move to… on the source that holds it (over the API, POST /api/admin/organizational/move with {"source_id": "<the second copy's id>"}). It is one act. The next ingest run compiles the crosswalk from the second copy's table:

prism-ingest crosswalk: compiling from hr_directory (the designated organizational context stream) in authoritative
crosswalk: 2 email from hr_directory.hr_directory_people (declared, exact)

The crosswalk is compiled from the second copy alone; the first copy's people are not merged in. The first copy keeps its table, and moving the stream back compiles from it again. Before you move, read Replacing an uploaded directory: it covers the anchor and the field names that keep the same questions giving the same answers, and the move onto a copy that has not landed.

People are resolved through the directory alone. A person id is looked up in the directory whichever source carries it. With hr_directory as the directory, an employee_id in any other source resolves to the person hr_directory lists under that id. A person the other account lists and hr_directory does not is not resolved. So when both accounts take their ids from one system, such as one HR system, an id resolves to the right person. When each account issues its own ids, one id can name two different people, and Prism resolves it to the directory's.

7. What the self test shows​

The self test has one CONTEXT STREAMS line per copy, headed by its label: People directory (Snowflake copy) for the first and People directory (Snowflake copy) (hr_directory) for the second. Each carries its own status, for example:

unverified · tested … · 0 of 2 verified

The identity crosswalk line names the copy that holds the directory:

hr_directory is designated and its crosswalk compiled from it: email:declared 2, github_login:declared 2

A source the installation's settings switch on at startup is never refused. So at every startup the log reports two things an enable would refuse, for every pair of enabled sources.

A crossed table read. The startup log names the pair:

{"source_registry": "crossed_table_read", "source": "hr_directory", "pointer": "/model/datasets/0/fields/7/sql", "reads": "snowflake_snapshot_people", "filled_by": "snowflake_snapshot"}

and the reading source's line warns:

… · /model/datasets/0/fields/7/sql reads snowflake_snapshot_people, a table 'snowflake_snapshot' fills, so it may read that source's rows; write {{ table }} there for this source's own table · this stream's questions may be affected; other streams are not

Two enabled sources under one label. The startup log names both:

{"source_registry": "label_clash", "label": "People directory (Snowflake copy)", "sources": ["hr_directory", "snowflake_snapshot"]}

Each copy's line also warns, naming the other. Give one of them a label of its own.