Enable the CDC service
The RAI Native App creates a Change Data Capture (CDC) service to manage a compute engine responsible for processing changes from Snowflake source tables and views. This guide explains how to enable and disable the CDC service, check its status, and resize its engine when needed.
- The RAI Native App is installed in your Snowflake account.
What the CDC service does
Section titled “What the CDC service does”The CDC service manages a compute engine that processes the change tracking data consumed by data streams to make changes to source data available to semantic models that depend on the streams’ data sources. This service fully manages the lifecycle of the CDC engine, including creating or resuming it when changes are detected and suspending it after inactivity.
Enable the CDC service
Section titled “Enable the CDC service”Requires the cdc_admin application role.
Enable CDC when you want the service to start processing source-data changes again. Use this task when you are turning CDC on for the first time or resuming it after a pause.
-- Enable the CDC service.CALL relationalai.app.resume_cdc();+--------------------------------------------------------------------+| CDC functionality on the RelationalAI application has been resumed |+--------------------------------------------------------------------+from relationalai.config import create_config
session = create_config().get_session()
# Enable the CDC service.session.sql("CALL relationalai.app.resume_cdc()").collect()Verify the CDC service is ready
Section titled “Verify the CDC service is ready”Requires the app_user application role.
Use this task after you enable or resume CDC. It helps you confirm that the service is enabled, that the CDC engine can process changes, and that the background task is running.
Run app.cdc_status(), then check CDC_ENABLED and CDC_ENGINE_STATUS:
-- Get the CDC service status.CALL relationalai.app.cdc_status();+--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------+| CDC_ENABLED | CDC_ENGINE_NAME | CDC_ENGINE_STATUS | CDC_ENGINE_SIZE | CDC_TASK_STATUS | CDC_TASK_INFO ||--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------|| TRUE | CDC_MANAGED_ENGINE | READY | HIGHMEM_X64_S | started | {"createdOn": "2024-10-15 21:58:11.291 -0700", "lastSuspendedOn": null, "lastSuspendedReason": null, "state": "started"} |+--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------+from relationalai.config import create_config
session = create_config().get_session()
# Get the CDC service status.rows = session.sql("CALL relationalai.app.cdc_status()").collect()print(rows)+--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------+| CDC_ENABLED | CDC_ENGINE_NAME | CDC_ENGINE_STATUS | CDC_ENGINE_SIZE | CDC_TASK_STATUS | CDC_TASK_INFO ||--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------|| TRUE | CDC_MANAGED_ENGINE | READY | HIGHMEM_X64_S | started | {"createdOn": "2024-10-15 21:58:11.291 -0700", "lastSuspendedOn": null, "lastSuspendedReason": null, "state": "started"} |+--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------+- The CDC service is ready if all of the following are true:
CDC_ENABLEDisTRUE, which confirms that the service is enabled.CDC_ENGINE_STATUSisREADY, which confirms that the CDC engine is running and can process changes.CDC_TASK_STATUSisstarted, which confirms that the background task that manages the CDC engine is running.
- For more info, the
CDC_TASK_INFOcolumn shows the latest task state details, such as when the task was created or last suspended.
View the CDC engine size
Section titled “View the CDC engine size”Requires the app_user application role.
Run app.cdc_status(), then check CDC_ENGINE_SIZE.
Use this when you want to confirm which engine size is active or verify that a resize took effect.
Run app.cdc_status():
-- Get the CDC service status.CALL relationalai.app.cdc_status();+--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------+| CDC_ENABLED | CDC_ENGINE_NAME | CDC_ENGINE_STATUS | CDC_ENGINE_SIZE | CDC_TASK_STATUS | CDC_TASK_INFO ||--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------|| TRUE | CDC_MANAGED_ENGINE | READY | HIGHMEM_X64_S | started | {"createdOn": "2024-10-15 21:58:11.291 -0700", "lastSuspendedOn": null, "lastSuspendedReason": null, "state": "started"} |+--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------+Create a Snowpark session, then run app.cdc_status():
from relationalai.config import create_config
session = create_config().get_session()
# Get the CDC service status.rows = session.sql("CALL relationalai.app.cdc_status()").collect()print(rows)+--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------+| CDC_ENABLED | CDC_ENGINE_NAME | CDC_ENGINE_STATUS | CDC_ENGINE_SIZE | CDC_TASK_STATUS | CDC_TASK_INFO ||--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------|| TRUE | CDC_MANAGED_ENGINE | READY | HIGHMEM_X64_S | started | {"createdOn": "2024-10-15 21:58:11.291 -0700", "lastSuspendedOn": null, "lastSuspendedReason": null, "state": "started"} |+--------------+--------------------+-------------------+------------------+-----------------+--------------------------------------------------------------------------------------------------------------------------+- The
CDC_ENGINE_SIZEcolumn shows the current size of the CDC engine, such asHIGHMEM_X64_SorHIGHMEM_X64_M.
Resize the CDC engine
Section titled “Resize the CDC engine”Requires the cdc_admin application role.
Resize the CDC engine when the default size is not sufficient for your workload, such as when change batches are large or processing latency is too high. The new size takes effect the next time a new processing batch starts.
When the RAI Native App is installed, the CDC engine starts with the HIGHMEM_X64_S size.
See Compute Pools for background on the available size options.
To change the size of the CDC engine, use the app.alter_cdc_engine_size() procedure:
-- Change the size of the CDC engine to HIGHMEM_X64_M.CALL relationalai.app.alter_cdc_engine_size('HIGHMEM_X64_M');+--------------------------------------+| CDC engine size set to HIGHMEM_X64_M |+--------------------------------------+To change the size of the CDC engine, create a Snowpark session from your default PyRel connection with create_config(), then call the app.alter_cdc_engine_size() procedure:
from relationalai.config import create_config
session = create_config().get_session()
# Change the size of the CDC engine to HIGHMEM_X64_M.session.sql("CALL relationalai.app.alter_cdc_engine_size('HIGHMEM_X64_M')").collect()Disable the CDC service
Section titled “Disable the CDC service”Requires the cdc_admin application role.
Disable CDC when you need to pause data stream processing, such as when you are investigating a problem or want to reduce costs during a period of inactivity. When CDC is disabled, the service suspends the CDC engine, which pauses all stream change processing until you re-enable CDC.
To disable the CDC service, use the app.suspend_cdc() procedure:
-- Disable the CDC service.CALL relationalai.app.suspend_cdc();+------+| NULL |+------+To disable the CDC service, create a Snowpark session from your default PyRel connection with create_config(), then call the app.suspend_cdc() procedure:
from relationalai.config import create_config
session = create_config().get_session()
# Disable the CDC service.session.sql("CALL relationalai.app.suspend_cdc()").collect()