使用 Snowsight 暂存文件¶
With Snowsight, you can create and manage named stages without writing SQL. You can also upload files onto a named internal stage so that you can view your files, reference the files in a Python worksheet, or load data from the files into a table.
You can’t upload files onto user stages or table stages using Snowsight. For more information about stages, see Overview of data loading.
创建暂存区
You can use Snowsight to create a named internal or external stage.
Note
To create a stage, you must use a role that is granted or inherits the necessary privileges. For more information, see Access control requirements for CREATE STAGE.
创建命名内部暂存区
To use Snowsight to create a named internal stage, do the following:
-
sign in to Snowsight.
-
at the top of the navigation menu, select
(Create) » Stage » Snowflake Managed. -
In the Create Stage dialog, enter a Stage Name.
-
Select the database and schema where you want to create the stage.
-
Optionally deselect Directory table. Directory tables let you see files on the stage, but require a warehouse and thus incur a cost. You can choose to deselect this option for now and enable a directory table later.
-
Select the type of Encryption supported for all files on your stage. For details, see encryption for internal stages. You can’t change the encryption type after you create the stage.
Note
To enable data access, use server-side encryption. Otherwise, staged files are client-side encrypted by default and unreadable when downloaded. For more information, see Server-side encryption for unstructured data access.
-
Complete the fields to describe your stage. For more information, see CREATE STAGE.
-
Select Create.
创建命名外部暂存区
To use Snowsight to create a named external stage, do the following:
-
sign in to Snowsight.
-
at the top of the navigation menu, select
(Create) » Stage » External Stage. -
Select your external cloud storage provider: Amazon S3, Microsoft Azure, or Google Cloud Platform.
-
In the Create Stage dialog, enter a Stage Name.
-
Select the database and schema where you want to create the stage.
-
Enter the URL of your external cloud storage location.
-
If your external storage isn’t public, enable Authentication and enter your details. For more information, see CREATE STAGE.
-
Optionally deselect Directory table. Directory tables let you see files on the stage, but require a warehouse and thus incur a cost. You can choose to deselect this option for now and enable a directory table later.
If you enable Directory table, optionally select Enable auto-refresh, and then select your event notification or notification integration to automatically refresh the directory table when files are added or removed. For more information, see Data Load Dirtables Auto.
-
If your files are encrypted, enable Encryption, and then enter your details.
-
(Optional) To view a generated SQL statement, expand the SQL Preview. To specify additional options for your stage, such as AUTO_REFRESH, you can open this SQL preview in a worksheet.
-
Select Create.
将文件上传到暂存区
You can use Snowsight to upload files onto a named internal stage.
要将文件上传到外部暂存区,请使用您的外部云服务(Amazon S3、Microsoft Azure 或 Google Cloud Storage)提供的工具。
将文件上传到命名内部暂存区
Note
文件大小上限为 250 MB。
To upload files onto an internal stage, you must use a role that is granted or inherits the USAGE privilege on the database and schema and the WRITE privilege on the stage. For more information, see Stage privileges.
要将文件上传到暂存区,请执行以下操作:
- Sign in to Snowsight.
- In the navigation menu, select Ingestion » Add Data.
- On the Add Data page, select Load files into a Stage.
- In the Upload Your Files dialog that appears, select the files that you want to upload. You can upload multiple files at the same time.
- 选择在其中创建暂存区的数据库架构,然后选择暂存区。
- (可选)在暂存区中选择或创建保存文件的路径。
- Select Upload.
将文件上传到暂存区之后,可以根据具体文件执行以下操作之一:
- Use the files in a Python worksheet. For more information, see Add a Python File from a Stage to a Worksheet.
- Copy data from the staged files into a table. For more information, see Load data into an existing table using Snowsight or Copy data from an internal stage.
- Query the data in the stage. For more information, see Query data in staged files.
查看暂存文件
You can view staged files using Snowsight. You can view files on both internal and external stages.
Note
必须使用被授予或继承对数据库和架构的 USAGE 权限以及对暂存区的 READ 权限的角色,才能执行这些步骤。
- Sign in to Snowsight.
- In the navigation menu, select Catalog » Database Explorer.
- 选择包含暂存区的数据库和架构。
- Select Stages and select the stage for which you want to view files.
- If prompted, select Enable Directory Table to enable a directory table for the stage so that you can see files.
- 如果显示提示,请选择一个仓库以刷新目录表。
若要刷新暂存区中的目录表,请选择刷新图标。
管理暂存文件
You can use Snowsight to take the following actions on staged files:
- Select
» Load into table to
load the file from the stage into a table. - Select
» Copy path to copy the path to the file for use elsewhere, such as in a worksheet.
对于内部暂存区中的文件,还可以执行以下操作:
- Select
» Download to download the file from the stage. - Select
» Remove to remove the file from the stage.
Note
To download a file from an external stage, see Download staged files in Snowsight.
管理暂存区
To manage a stage in Snowsight, do the following:
Note
必须使用被授予或继承对数据库和架构的 USAGE 权限以及对暂存区的 OWNERSHIP 权限的角色,才能执行这些步骤。
- Sign in to Snowsight.
- In the navigation menu, select Catalog » Database Explorer.
- 选择包含暂存区的数据库和架构。
- Select Stages and select the stage.
- Select Stage Details.
可以通过以下方式管理暂存区:
- Select
» Edit to edit properties or enable a directory table for the stage object. - Select
» Clone to clone the stage. - Select
» Drop to drop, or remove, the stage. - Select
» Transfer Ownership to transfer OWNERSHIP privileges of the stage to another role.
If you want to manage privileges for the stage, use the Privileges section to view, grant, and revoke privileges.
故障排除
外部暂存区中的文件不可见
当外部暂存区未启用目录表,或者有关外部存储位置的信息不正确时,就可能会出现此问题。
要解决此问题,请尝试以下操作:
- Make sure the stage owner has enabled a directory table on the stage.
- Check that the directory table has been refreshed. To refresh the directory table, select your stage in Snowsight, then select the refresh icon.
- 验证云提供商 URL 是否正确。如果 URL 包含子路径,请确保末尾带有一个斜杠。
Upload Files 按钮不可用(未激活)¶
如果您不具备将文件上传到内部暂存区所需的权限,或者系统正在进行其他上传时,就可能会出现此问题。
要解决此问题,请尝试以下操作:
- 确保已选择内部暂存区。
- 使用被授予或继承对数据库和架构的 USAGE 权限以及对暂存区的 WRITE 权限的角色。
- Check whether another upload is in progress. Hovering over the inactive button displays information about any in-progress uploads. Snowsight also displays a notification for in-progress uploads. If another upload is in progress, it must complete before you can upload additional files onto the stage.