Variables
Learn how to use Runtime & Environment Variables with Sling
Runtime Variables
A powerful logic which allows dynamic configuration. The used parts will be replaced at runtime with the corresponding values. So you could name your target object {target_schema}.{stream_schema}_{stream_table}
, and at runtime it will be formatted correctly as depicted below.
run_timestamp
: The run timestamp of the task (2006_01_02_150405
)source_account
: the name of the account of the source connection (when source conn is AZURE)source_bucket
: the name of the bucket of the source connection (when source conn is GCS or S3)source_container
: the name of the container of the source connection (when source conn is AZURE)source_name
: the name of the source connectionstream_file_folder
: the file parent folder name of the stream (when source is a file system)stream_file_name
: the file name of the stream (when source is a file system)stream_file_ext
: the file extension of the stream (when source is a file system)stream_file_path
: the file path of the stream (when source is a file system)stream_name
: the name of the streamstream_schema
: the schema name of the source stream (when source is a database)stream_table
: the table name of the source stream (when source is a database)target_account
: the name of the account of the target connection (when target is AZURE)target_bucket
: the name of the bucket of the target connection (when target is GCS or S3)target_container
: the name of the container of the target connection (when target is AZURE)target_name
: the name of the target connectiontarget_schema
: the default target schema defined in connection (when target is a database)object_schema
: the target object table schema (when target is a database)object_table
: the target object table name (when target is a database)object_name
: the target object name
Timestamp Patterns
YYYY
: The 4 digit year of the run timestamp of the taskYY
: The 2 digit year of the run timestamp of the taskMMM
: The abbreviation of the month of the run timestamp of the taskMM
: The 2 digit month of the run timestamp of the taskDD
: The 2 digit day of the run timestamp of the taskHH
: The 2 digit 24-hour of the run timestamp of the taskhh
: The 2 digit 12-hour of the run timestamp of the taskmm
: The 2 digit minute of the run timestamp of the taskss
: The 2 digit second of the run timestamp of the taskISO8601
: The ISO-8601 format of the run timestamp of the task (2006-01-02T15:04:05Z
)
Environment Variables
Sling also allows you to pass-in environment variables in order to further customize configurations in a scalable manner. We are then able to reuse them in various places in our config files.
Definition
A convenient way to embed global variables is in the env.yaml
file. You could also simply define it in the environment, the traditional way.
Replication
Below we are displaying the full use of Environment Variables as well as Runtime Vars (such as stream_schema
, stream_table
, YYYY
, MM
and DD
).
Global Environment Variables
Sling utilizes the following global environment variables to further configure the load behavior. You can simply define them in your environment, the env.yaml
file or the env
section in a task or replication.
Variable Name | Description |
---|---|
| The sling home directory, which contains |
| Whether to add an audit timestamp column named |
| If source is file, whether to add a column |
| The number limit of file names to pull, when listing from cloud file systems such as S3, GCP and Azure Storage. |
| Whether to add a column named |
| If source is file, whether to add a column named |
| This is useful to create tables / files using the stream columns structure, even if there is no data. To enable, set to |
| Tells sling to keep any temporary files or tables created in the load process. To enable, set to |
| Provide the body of the |
| this disables any anonymous usage reporting. These are used to improve sling. To disable, set this to |
| Whether the progress of the stream should be displayed ( |
| How sling formats the log lines. Accepts values |
| The number of records to process in order to infer column types (especially for file sources). Default is |
Last updated