snowflake.snowpark.functions.build_stage_file_url

snowflake.snowpark.functions.build_stage_file_url(stage_name: str, relative_file_path: str) Column[source]

Generates a Snowflake file URL to a staged file using the stage name and relative file path as inputs. A file URL permits prolonged access to a specified file. That is, the file URL does not expire. The file URL is in the following format:

https://<account_identifier>/api/files/<db_name>/<schema_name>/<stage_name>/<relative_path>

See more details here.

Parameters:
  • stage_name – Name of the internal or external stage where the file is stored. If the stage name includes spaces or special characters, it must be enclosed in single quotes (e.g. ‘@”my stage”’ for a stage named “my stage”). It has to be a constant instead of a column expression.

  • relative_file_path – Path and filename of the file relative to its location in the stage. It has to be a constant instead of a column expression.

Example:

>>> df.select(build_stage_file_url("@images_stage", "/us/yosemite/half_dome.jpg").alias("url")).collect()  
Copy