EXECUTE SERVICE

Important

The Snowpark Container Services job feature is currently in private preview and is subject to Preview Terms at https://snowflake.com/legal. Contact your Snowflake representative for more information.

Starts a Snowpark Container Services job. The job runs synchronously; it completes after all the containers exit.

See also:

SYSTEM$GET_JOB_STATUS , SYSTEM$GET_JOB_LOGS

Syntax

EXECUTE SERVICE
  IN COMPUTE POOL <compute_pool_name>
  {
    FROM @<stage>
    SPECIFICATION_FILE = '<yaml_file_stage_path>'
    |
    FROM SPECIFICATION <specification_text>
  }
  [ EXTERNAL_ACCESS_INTEGRATIONS = ( <EAI_name> [ , ... ] ) ]
Copy

Required parameters

IN COMPUTE POOL compute_pool_name

Specifies the name of the compute pool in your account on which to run the service.

FROM stage

Specifies the Snowflake internal stage where the specification file is stored; for example, @tutorial_stage.

SPECIFICATION_FILE = 'yaml_file_stage_path'

Specifies the path to the service specification file on the stage; for example, 'some-dir/echo_spec.yaml'.

FROM SPECIFICATION specification_text

Specifies service specification. You can use a pair of dollar signs ($$) to delimit the beginning and ending of the specification string.

Optional parameters

EXTERNAL_ACCESS_INTEGRATIONS = ( EAI_name [ , ... ] )

Specifies the names of the external access integrations that allow your job to access external sites. The names in this list are case-sensitive. By default, application containers don’t have permission to access the internet. If you want to allow your job to access an external site, create an External Access Integration (EAI), and configure your job to use that integration. For more information, see Network egress.

Access control requirements

A role used to execute this SQL command must have the following privileges at a minimum:

Privilege

Object

Notes

USAGE

Compute pool

READ

Stage

This is the stage where the specification is stored.

READ

Image Repository

Repository of images referenced by the specification.

Note that operating on any object in a schema also requires the USAGE privilege on the parent database and schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Usage notes

  • The query ID that the EXECUTE SERVICE command returns is a unique identifier for the Snowpark Container Services job.

    You can use this ID to retrieve job status (SYSTEM$GET_JOB_STATUS) or logs from a job container (SYSTEM$GET_JOB_LOGS) while the job is in progress.

    Note that you can call the LAST_QUERY_ID function immediately after running the EXECUTE SERVICE command to capture the ID of the query job for later reference. You can also use the Snowsight web interface to find the query ID of the job.

  • Regarding metadata:

    Attention

    Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata Fields in Snowflake.

Examples

Create a Snowpark Container Services job:

EXECUTE SERVICE
  IN COMPUTE POOL tutorial_compute_pool
  FROM @tutorial_stage
  SPECIFICATION_FILE='my_job_spec.yaml';
Copy