Skip to main content
code.register_dataset registers a Snowflake table or view as a Narrative dataset in code, without launching the Native App’s Configuration screen — from a worksheet, the Snowflake SQL API, or a scheduled task. Use it to script dataset onboarding, or to run it from the pipeline that already builds the table. The Configuration screen is unchanged and is still the simplest way to register your first dataset. Both routes produce the same dataset, and both depend on the app having been installed and configured once — see Install the Snowflake Native App for that setup. If you have not registered a dataset this way before, Register Your First Snowflake Dataset walks one table through end to end. This page is the reference for the procedures themselves.

Prerequisites

  • The Snowflake Native App installed and configured. That setup creates the Narrative data plane the dataset attaches to.
  • At least one warehouse granted to the application, because every job the operator later runs against the dataset — health checks, samples, statistics, deliveries — needs one. This grant cannot be requested through Snowflake’s reference framework and has to be run by an ACCOUNTADMIN:
  • The dataset_registration application role, or app_admin.
  • A session whose current database is the application. These procedures read the Narrative API token through a reference that resolves against the caller’s current database, not the procedure’s, so every example below opens with use database narrative_data_collaboration;.

Grant the registration role

dataset_registration carries usage on the two registration procedures and read access to data.mappings, where the application records what it has registered. Nothing else. The procedures run with owner’s rights, so a caller needs no privilege on the application’s own state.
app_admin also works, since it holds dataset_registration. Prefer the smaller role for anyone whose job is registering datasets — app_admin additionally grants full write access to the application’s state, every function it exposes, and its compute pools and services.
Neither role confers anything in your account outside the application, and neither can read your tables. The application reaches a source object only through the reference you mint for it, one object at a time.

Register a table or view

code.register_dataset describes the object, derives its schema, creates and activates the dataset, and returns the new dataset_id. The source object is passed as a system$reference, which binds it through Snowflake’s reference framework. Nothing is granted to the application, Snowflake lists the binding among the app’s references, and deleting the dataset unbinds it again.
The nested arguments matter: system$reference runs as your role, so you need select and references on the object to call it. An object can be bound only once, so a second system$reference for a table that is already bound is rejected. data.mappings records what this application has registered, and the dataset_registration role can read it:

Arguments

What it returns

unsupported_columns is not an error. The dataset registers without those columns, so check this field if a column you expected is missing downstream.

Override the inferred schema

By default the schema comes from desc table or desc view, with variant, array and object columns resolved by sampling 1000 rows. code.infer_dataset_schema returns what register_dataset would infer — the schema, unsupported_columns, and the reference_alias — without creating the dataset:
infer_dataset_schema binds the reference, exactly as register_dataset does, and an object can be bound only once. The registration that follows must therefore address the object by the reference_alias this call returns. Minting a second system$reference for the same object fails with The same object cannot be added more than once.
Edit the schema it returns and pass it back as schema_override, addressing the object by that reference_alias. Inference is then skipped entirely, including the sampling:
The format is Narrative’s dataset schema: an object whose properties map column names to types, where a type is one of string, long, double, boolean, timestamptz, {"type":"array","items":…}, or {"type":"object","properties":{…}}. Property names must match the column names Snowflake reports, which are upper-case unless the column was created quoted. Do not include file_config — the procedure adds it.

Errors

Every failure names its remedy. The full list of messages and what each one means is in the Snowflake Native App reference.

Troubleshooting

The registration procedures are created when the application’s setup completes. If register_dataset is missing, that setup has not finished. Complete it, then:
This returns external access integration not available if the integration still is not bound.
Everything here is a stored procedure, so it is invoked with CALL and cannot be used inside a SELECT expression. Snowflake reports that as Unknown user-defined function, which reads like the procedure is missing when it is only being called the wrong way.
The dataset keeps pointing at the old object. Remove it and register the replacement.

Remove a dataset

Removing a dataset goes through the Narrative API. This procedure is granted to app_admin only:
The application then removes its own mapping row and unbinds the reference, so the source object is free to register again. That cleanup is asynchronous: the 200 means the delete was accepted, not that it has finished. If you are scripting delete-then-re-register, poll narrative_data_collaboration.data.mappings until the row disappears before binding the object again.

Install the Snowflake Native App

One-time setup, and registering a dataset through the Configuration screen

Snowflake Native App Reference

Capabilities, requirements, privileges, and naming conventions

Data Planes

How a customer-hosted data plane executes work

Compute Pools

The warehouses that run jobs against your registered datasets