Skip to content

Procedures and Functions

All procedures run as EXECUTE AS OWNER. Internal procedures (prefixed with _) are omitted.

Encode a feature array using a trained encoder.

SELECT <app_name>.core.encode('sales', ARRAY_CONSTRUCT(350000, 1800, 3, 2));
-- Returns: [0.23, -0.41, 0.87, 0.12, ...]
ParameterTypeDescription
modelVARCHAREncoder name
inputARRAYFeature values
ReturnsARRAYLatent vector

core.train_encoder(name, source_table, feature_columns, [latent_dims], [epochs], [batch_size], [passthrough_columns], [allow_identifiers])

Section titled “core.train_encoder(name, source_table, feature_columns, [latent_dims], [epochs], [batch_size], [passthrough_columns], [allow_identifiers])”

Train an autoencoder on bound data. Async. Retraining an existing encoder archives the previous version.

CALL <app_name>.core.train_encoder(
'sales',
'my_db.my_schema.sales',
ARRAY_CONSTRUCT('price', 'sqft', 'bedrooms', 'bathrooms')
);

With all options:

CALL <app_name>.core.train_encoder(
'sales',
'my_db.my_schema.sales',
ARRAY_CONSTRUCT('price', 'sqft', 'bedrooms', 'bathrooms'),
16, 100, 256,
ARRAY_CONSTRUCT('year_built')
);
ParameterTypeDefaultDescription
nameVARCHARrequiredEncoder name
source_tableVARCHARrequiredFully qualified table name (must be bound)
feature_columnsARRAYrequiredColumns to encode
latent_dimsINTEGER16Output vector dimension
epochsINTEGER100Training epochs
batch_sizeINTEGER256Batch size
passthrough_columnsARRAY[]Columns included in view but not encoded
allow_identifiersBOOLEANFALSEAllow identifier columns in passthrough
ReturnsVARCHARJob ID. Poll training_jobs_v for status.

Cancel a running job. The training service checks for cancellation every 10 epochs.

CALL <app_name>.core.cancel_training_job('abc123');

core.schedule_training(encoder_name, schedule, [row_threshold])

Section titled “core.schedule_training(encoder_name, schedule, [row_threshold])”

Schedule automatic retraining via cron or interval. Optional row-count growth trigger.

CALL <app_name>.core.schedule_training(
'sales', 'USING CRON 0 2 * * 0 UTC'
);

With a growth threshold (skips retraining until the source table grows past this count):

CALL <app_name>.core.schedule_training(
'sales', '1 HOUR', 10000
);

Remove a scheduled retraining task.

CALL <app_name>.core.unschedule_training('sales');

core.create_view_from_encoder(encoder_name)

Section titled “core.create_view_from_encoder(encoder_name)”

Generate a secure view from encoder metadata. Creates app_runtime.<name>_v with passthrough columns and a features array. Masking and tokenization policies are applied automatically.

CALL <app_name>.core.create_view_from_encoder('sales');

core.protect_column(view, column, [encoder_name], [bypass_roles])

Section titled “core.protect_column(view, column, [encoder_name], [bypass_roles])”

Apply encoding masking policy to a column. Encoder is inferred from the view name (strips _v suffix) unless specified.

CALL <app_name>.core.protect_column(
'my_db.my_schema.sales_v', 'features'
);

With explicit encoder and bypass roles:

CALL <app_name>.core.protect_column(
'my_db.my_schema.employees', 'salary',
'salary_encoder',
ARRAY_CONSTRUCT('SYSADMIN', 'HR_ADMIN')
);

Remove encoding masking policy from a column.

CALL <app_name>.core.unprotect_column(
'my_db.my_schema.sales_v', 'features'
);

core.protect_passthrough(view, column, encoder_name, [bypass_roles])

Section titled “core.protect_passthrough(view, column, encoder_name, [bypass_roles])”

Apply tokenization masking policy to a passthrough column. Called automatically by create_view_from_encoder.

CALL <app_name>.core.protect_passthrough(
'my_db.my_schema.sales_v', 'year_built', 'sales'
);

Remove tokenization policy from a passthrough column.

CALL <app_name>.core.unprotect_passthrough(
'my_db.my_schema.sales_v', 'year_built'
);

core.register_encoder(name, path, input_dims, output_dims, ...)

Section titled “core.register_encoder(name, path, input_dims, output_dims, ...)”

Register an existing ONNX model from stage. Archives previous version if the encoder name exists. Full 12-parameter signature visible in the Snowsight object explorer.

CALL <app_name>.core.register_encoder(
'my_encoder', '@app_state.encoders/my_encoder.onnx', 10, 8
);

Soft-delete. Deactivates the encoder but keeps the registry row.

CALL <app_name>.core.unregister_encoder('sales');

Hard-delete. Removes the ONNX stage file and registry row. Unprotect columns referencing this encoder first.

CALL <app_name>.core.delete_encoder('sales', TRUE);

core.rollback_encoder(encoder_name, version_num)

Section titled “core.rollback_encoder(encoder_name, version_num)”

Restore a previous archived version. Archives the current version, copies the old ONNX file back, reloads the model.

CALL <app_name>.core.rollback_encoder('sales', 1);

core.prune_encoder_versions(encoder_name, keep_n)

Section titled “core.prune_encoder_versions(encoder_name, keep_n)”

Remove old archived versions beyond the most recent keep_n. Deletes stage files and version records.

CALL <app_name>.core.prune_encoder_versions('sales', 3);

Requires app_admin.

Create compute pools, warehouse, and start services. Runs automatically when privileges are granted. Call manually for recovery or after changing compute configuration.

CALL <app_name>.core.start_services();

Drop services, compute pools, and warehouse. Call before uninstalling.

CALL <app_name>.core.stop_services();

Block until both services reach READY. Default timeout: 600 seconds.

CALL <app_name>.core.wait_for_services();

Diagnostic output for both services including container state and logs.

CALL <app_name>.core.service_status();

Switch between cpu and gpu. Call start_services() to apply.

CALL <app_name>.core.set_training_compute('gpu');
CALL <app_name>.core.start_services();

Scale encoding compute. Call start_services() to apply.

CALL <app_name>.core.set_encoding_instance('CPU_X64_M');
CALL <app_name>.core.start_services();

Options: CPU_X64_XS (default), CPU_X64_S, CPU_X64_M, CPU_X64_SL, CPU_X64_L, HIGHMEM_X64_S, HIGHMEM_X64_M.