Skip to content

Cube Lifecycle

The procedures in this section manage the lifecycle of a cube and its application-owned objects.

Minimum role: CUBE_ADMIN

CLONE_CUBE(P_SOURCE_CUBE, P_TARGET_CUBE, P_REBUILD) -> VARCHAR

Copies a cube to a new name, including its configuration, dimensions, formulas, saved queries, variables, Dynamic Time Series settings, and security rules.

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.

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.

CALL CUBE.CLONE_CUBE('FINANCE', 'FINANCE_SANDBOX', TRUE);

Minimum role: CUBE_ADMIN

DROP_CUBE(P_CUBE_NAME, P_CONFIRM) -> VARCHAR

Permanently removes a cube, including its dimensions, formulas, variables, saved queries, security rules, fact table, and consumer views.

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.

Preview:

CALL CUBE.DROP_CUBE('OLD_CUBE', FALSE);

Execute:

CALL CUBE.DROP_CUBE('OLD_CUBE', TRUE);

Minimum role: CUBE_ADMIN

CLEAR_CUBE_DATA(P_CUBE_NAME, P_CONFIRM) -> VARCHAR

Removes 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.

Parameter Type Req/Opt Description
P_CUBE_NAME VARCHAR req Cube name.
P_CONFIRM BOOLEAN opt Must be TRUE to proceed.
CALL CUBE.CLEAR_CUBE_DATA('FINANCE', TRUE);

Minimum role: CUBE_ADMIN

EXPORT_CUBE_CONFIG(P_CUBE_NAME) -> VARIANT

Exports 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.

Parameter Type Req/Opt Description
P_CUBE_NAME VARCHAR req Cube to export.

Returns the cube configuration as a VARIANT JSON object.

CALL CUBE.EXPORT_CUBE_CONFIG('FINANCE');

Minimum role: CUBE_ADMIN

IMPORT_CUBE_CONFIG(P_CONFIG_JSON, P_OVERWRITE) -> VARIANT

Recreates a cube from a configuration previously produced by EXPORT_CUBE_CONFIG.

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 a VARIANT result describing the import operation.

CALL CUBE.IMPORT_CUBE_CONFIG('<json>', FALSE);

Minimum role: CUBE_ADMIN

REIMPORT_CUBE_SOURCE(P_CUBE_NAME, P_REBUILD) -> VARIANT

Re-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.

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 a VARIANT result describing the re-import operation.

CALL CUBE.REIMPORT_CUBE_SOURCE('FINANCE', TRUE);

Minimum role: CUBE_ADMIN

DROP_TABLE(DROP_TABLE) -> VARCHAR

Drops an application-owned table from SHARED_DATA, such as an obsolete dimension source, stale extract, or old reporting table.

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.

CALL CUBE.DROP_TABLE('SHARED_DATA.OLD_EXTRACT');