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_registrationapplication role, orapp_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.
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.
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
Override the inferred schema
By default the schema comes fromdesc 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:
schema_override, addressing the object by that reference_alias. Inference is then skipped entirely, including the sampling:
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
Unknown function CODE.REGISTER_DATASET
Unknown function CODE.REGISTER_DATASET
The registration procedures are created when the application’s setup completes. If This returns
register_dataset is missing, that setup has not finished. Complete it, then:external access integration not available if the integration still is not bound.Unknown user-defined function
Unknown user-defined function
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.A registered dataset stops working after the source is dropped or renamed
A registered dataset stops working after the source is dropped or renamed
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 toapp_admin only:
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.
Related content
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

