Cube Lifecycle
The procedures in this section manage the lifecycle of a cube and its application-owned objects.
CLONE_CUBE
Section titled “CLONE_CUBE”Minimum role: CUBE_ADMIN
CLONE_CUBE(P_SOURCE_CUBE, P_TARGET_CUBE, P_REBUILD) -> VARCHARCopies a cube to a new name, including its configuration, dimensions, formulas, saved queries, variables, Dynamic Time Series settings, and security rules.
Parameters
Section titled “Parameters”| Parameter | Type | Req/Opt | Description |
|---|---|---|---|
P_SOURCE_CUBE |
VARCHAR |
req | Cube to clone from. |
P_TARGET_CUBE |
VARCHAR |
req | New cube name. May contain letters, digits, and underscores; must start with a letter or underscore; must not already exist. |
P_REBUILD |
BOOLEAN |
opt | When TRUE, also builds the clone’s structures and clones its fact table. When FALSE, clones configuration only. |
Behavior
Section titled “Behavior”With P_REBUILD = TRUE, the clone receives its own fact table through a Snowflake zero-copy clone. It contains the source cube’s data as of clone time and can diverge independently afterward.
With P_REBUILD = FALSE, only configuration is copied. No fact table is created, dimensions remain inactive, and formulas remain pending. The cube is not queryable until it is cloned again with TRUE.
The clone intentionally shares the source cube’s dimension source tables. These are read-only build inputs. If the source cube is dropped, the clone loses the ability to rebuild from those shared source tables, although already-built structures continue to work.
Scheduled saved queries are cloned as suspended schedules and point to different output tables so the clone cannot materialize over the source cube’s data.
Example
Section titled “Example”CALL CUBE.CLONE_CUBE('FINANCE', 'FINANCE_SANDBOX', TRUE);DROP_CUBE
Section titled “DROP_CUBE”Minimum role: CUBE_ADMIN
DROP_CUBE(P_CUBE_NAME, P_CONFIRM) -> VARCHARPermanently removes a cube, including its dimensions, formulas, variables, saved queries, security rules, fact table, and consumer views.
Parameters
Section titled “Parameters”| Parameter | Type | Req/Opt | Description |
|---|---|---|---|
P_CUBE_NAME |
VARCHAR |
req | Cube to delete. |
P_CONFIRM |
BOOLEAN |
opt | FALSE previews what would be deleted. TRUE performs the deletion. |
The cube’s audit history is retained.
Examples
Section titled “Examples”Preview:
CALL CUBE.DROP_CUBE('OLD_CUBE', FALSE);Execute:
CALL CUBE.DROP_CUBE('OLD_CUBE', TRUE);CLEAR_CUBE_DATA
Section titled “CLEAR_CUBE_DATA”Minimum role: CUBE_ADMIN
CLEAR_CUBE_DATA(P_CUBE_NAME, P_CONFIRM) -> VARCHARRemoves all fact data from a cube while preserving its structure, dimensions, and formulas. Use this before a full reload when you want to keep the model intact.
Parameters
Section titled “Parameters”| Parameter | Type | Req/Opt | Description |
|---|---|---|---|
P_CUBE_NAME |
VARCHAR |
req | Cube name. |
P_CONFIRM |
BOOLEAN |
opt | Must be TRUE to proceed. |
Example
Section titled “Example”CALL CUBE.CLEAR_CUBE_DATA('FINANCE', TRUE);EXPORT_CUBE_CONFIG
Section titled “EXPORT_CUBE_CONFIG”Minimum role: CUBE_ADMIN
EXPORT_CUBE_CONFIG(P_CUBE_NAME) -> VARIANTExports a cube’s complete configuration as JSON.
The export includes structure and settings only. It does not include fact data.
Use this before an upgrade or a significant modeling change when you want a restorable copy of the cube configuration.
Parameters
Section titled “Parameters”| Parameter | Type | Req/Opt | Description |
|---|---|---|---|
P_CUBE_NAME |
VARCHAR |
req | Cube to export. |
Returns
Section titled “Returns”Returns the cube configuration as a VARIANT JSON object.
Example
Section titled “Example”CALL CUBE.EXPORT_CUBE_CONFIG('FINANCE');IMPORT_CUBE_CONFIG
Section titled “IMPORT_CUBE_CONFIG”Minimum role: CUBE_ADMIN
IMPORT_CUBE_CONFIG(P_CONFIG_JSON, P_OVERWRITE) -> VARIANTRecreates a cube from a configuration previously produced by EXPORT_CUBE_CONFIG.
Parameters
Section titled “Parameters”| Parameter | Type | Req/Opt | Description |
|---|---|---|---|
P_CONFIG_JSON |
VARCHAR |
req | JSON produced by EXPORT_CUBE_CONFIG. |
P_OVERWRITE |
BOOLEAN |
opt | Whether to overwrite an existing cube with the same name. |
Returns
Section titled “Returns”Returns a VARIANT result describing the import operation.
Example
Section titled “Example”CALL CUBE.IMPORT_CUBE_CONFIG('<json>', FALSE);REIMPORT_CUBE_SOURCE
Section titled “REIMPORT_CUBE_SOURCE”Minimum role: CUBE_ADMIN
REIMPORT_CUBE_SOURCE(P_CUBE_NAME, P_REBUILD) -> VARIANTRe-runs a cube’s metadata import using the source path recorded when the cube was originally imported. You do not need to provide the stage path again.
Parameters
Section titled “Parameters”| Parameter | Type | Req/Opt | Description |
|---|---|---|---|
P_CUBE_NAME |
VARCHAR |
req | Cube to re-import. |
P_REBUILD |
BOOLEAN |
opt | When TRUE, rebuilds all dimensions after re-importing the metadata. |
This procedure returns an error if the cube has no recorded source path. Cubes created directly from tables, or cubes imported before source tracking was available, do not have a recorded source.
Returns
Section titled “Returns”Returns a VARIANT result describing the re-import operation.
Example
Section titled “Example”CALL CUBE.REIMPORT_CUBE_SOURCE('FINANCE', TRUE);DROP_TABLE
Section titled “DROP_TABLE”Minimum role: CUBE_ADMIN
DROP_TABLE(DROP_TABLE) -> VARCHARDrops an application-owned table from SHARED_DATA, such as an obsolete dimension source, stale extract, or old reporting table.
Parameters
Section titled “Parameters”| Parameter | Type | Req/Opt | Description |
|---|---|---|---|
DROP_TABLE |
VARCHAR |
req | Table name qualified with the schema, for example SHARED_DATA.MY_TABLE. |
Only tables in SHARED_DATA can be dropped, and the table name must be schema-qualified. An unqualified table name is rejected.
Example
Section titled “Example”CALL CUBE.DROP_TABLE('SHARED_DATA.OLD_EXTRACT');