Procedures and Functions
All procedures run as EXECUTE AS OWNER. Internal procedures (prefixed with _) are omitted.
Encoding
Section titled “Encoding”core.encode(model, input)
Section titled “core.encode(model, input)”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, ...]| Parameter | Type | Description |
|---|---|---|
model | VARCHAR | Encoder name |
input | ARRAY | Feature values |
| Returns | ARRAY | Latent vector |
Training
Section titled “Training”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'));| Parameter | Type | Default | Description |
|---|---|---|---|
name | VARCHAR | required | Encoder name |
source_table | VARCHAR | required | Fully qualified table name (must be bound) |
feature_columns | ARRAY | required | Columns to encode |
latent_dims | INTEGER | 16 | Output vector dimension |
epochs | INTEGER | 100 | Training epochs |
batch_size | INTEGER | 256 | Batch size |
passthrough_columns | ARRAY | [] | Columns included in view but not encoded |
allow_identifiers | BOOLEAN | FALSE | Allow identifier columns in passthrough |
| Returns | VARCHAR | Job ID. Poll training_jobs_v for status. |
core.cancel_training_job(job_id)
Section titled “core.cancel_training_job(job_id)”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);core.unschedule_training(encoder_name)
Section titled “core.unschedule_training(encoder_name)”Remove a scheduled retraining task.
CALL <app_name>.core.unschedule_training('sales');Views and Protection
Section titled “Views and Protection”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'));core.unprotect_column(view, column)
Section titled “core.unprotect_column(view, column)”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');core.unprotect_passthrough(view, column)
Section titled “core.unprotect_passthrough(view, column)”Remove tokenization policy from a passthrough column.
CALL <app_name>.core.unprotect_passthrough( 'my_db.my_schema.sales_v', 'year_built');Encoder Management
Section titled “Encoder Management”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);core.unregister_encoder(encoder_name)
Section titled “core.unregister_encoder(encoder_name)”Soft-delete. Deactivates the encoder but keeps the registry row.
CALL <app_name>.core.unregister_encoder('sales');core.delete_encoder(encoder_name, force)
Section titled “core.delete_encoder(encoder_name, force)”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);Operations
Section titled “Operations”Requires app_admin.
core.start_services()
Section titled “core.start_services()”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();core.stop_services()
Section titled “core.stop_services()”Drop services, compute pools, and warehouse. Call before uninstalling.
CALL <app_name>.core.stop_services();core.wait_for_services([timeout_secs])
Section titled “core.wait_for_services([timeout_secs])”Block until both services reach READY. Default timeout: 600 seconds.
CALL <app_name>.core.wait_for_services();core.service_status()
Section titled “core.service_status()”Diagnostic output for both services including container state and logs.
CALL <app_name>.core.service_status();core.set_training_compute(mode)
Section titled “core.set_training_compute(mode)”Switch between cpu and gpu. Call start_services() to apply.
CALL <app_name>.core.set_training_compute('gpu');CALL <app_name>.core.start_services();core.set_encoding_instance(family)
Section titled “core.set_encoding_instance(family)”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.