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.
Prerequisites
- The Snowflake Native App installed, with its external access integration and API token configured. These also create 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.
Grant the registration role
dataset_registration carries usage on the two registration procedures and read access to the app’s mapping table, and nothing else. The procedures run with owner’s rights, so a caller needs no privilege on the source object, the API token, or the app’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. There are two ways to give it the source object.
- By reference (recommended)
- By fully qualified name
system$reference mints a token that binds the object 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.system$reference for the same table is rejected with “The same object cannot be added more than once” — including when the Configuration screen bound it. To register an object that is already bound, pass its alias in place of the reference:
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, without creating anything:
infer_dataset_schema takes object_type and source exactly as register_dataset does, which means passing a system$reference token here will bind the reference. Pass a qualified name or an already-bound alias when you only want to look.schema_override. 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
The procedure validates before it changes anything, and every failure names its remedy.Troubleshooting
Unknown function CODE.REGISTER_DATASET
Unknown function CODE.REGISTER_DATASET
The procedure is created once the external access integration is bound, and recreated on every app upgrade. If it is missing, the integration or the API token is not configured. Configure them, then force the pass:This returns
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.code.call_narrative_api calls it with the account’s configured token, and is granted to app_admin only:
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

