INCLUDE SCRIPT

Inlines a script's SQL at the current location for reuse across pipelines.

Category: pipelineDeltaForge extension

Syntax

INCLUDE SCRIPT '<script_name>' [FROM WORKSPACE '<workspace_name>']

Description

## Overview Inlines the SQL content of a referenced script at the point where the INCLUDE SCRIPT statement appears. This provides a mechanism for code reuse across pipelines, allowing common transformation logic, staging operations, or utility queries to be maintained in a single location and shared. During pipeline execution, the INCLUDE SCRIPT directive is resolved before statements are executed. The referenced script's SQL is substituted in place of the INCLUDE directive. ## Behavior - The script name is resolved against the catalog's registered scripts. Scripts are SQL files within a workspace that do not contain a PIPELINE declaration. - Resolution order: first, the name is matched against registered script entity references; second, it is matched as a relative file path within the workspace. - When FROM WORKSPACE is specified, resolution is scoped to the named workspace. The current user must have access to the target workspace. - INCLUDE SCRIPT is a compile-time directive. The SQL is inlined before execution begins, not fetched dynamically at runtime. - Circular includes (script A includes script B which includes script A) are detected and produce an error. - The included SQL inherits the pipeline's execution context, including any DEFAULTS parameters defined in the PIPELINE header. ## Access Control | Privilege | Object | Notes | |-----------|--------|-------| | Read access | Source workspace | Required when including scripts from another workspace via FROM WORKSPACE. | ## Compatibility INCLUDE SCRIPT is a DeltaForge extension. It has no equivalent in standard SQL. The FROM keyword after the script name must be followed by WORKSPACE; using FROM without WORKSPACE is a parse error.

Parameters

NameTypeDescription
script_nameSpecifies the script name or entity reference to include. This is a quoted string that identifies either a registered script name in the catalog or a relative file path within the workspace (e.g., 'Scripts/shared_views.sql').
workspace_nameSpecifies the workspace from which to resolve the script. When omitted, the script is resolved from the current pipeline's workspace. Use this to share common SQL across workspaces.

Examples

-- Include a script from the same workspace
INCLUDE SCRIPT 'common_transforms';
-- Include a script using a file path
INCLUDE SCRIPT 'Scripts/shared_views.sql';
-- Include a script from a different workspace
INCLUDE SCRIPT 'Scripts/shared_views.sql' FROM WORKSPACE 'shared_etl';
-- Pipeline with included scripts
PIPELINE daily_reporting
  DESCRIPTION 'Daily reporting with shared transforms'
  SCHEDULE '0 8 * * *';

INCLUDE SCRIPT 'staging_transforms';
INCLUDE SCRIPT 'dimension_lookups' FROM WORKSPACE 'shared_etl';

INSERT INTO reporting.daily_summary
SELECT * FROM staging.transformed_data;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →