Stage
On this page
Stage is a managed file storage service that helps you organize and manage local files for ingestion into your SingleStore database(s).
Note
The workspace group must be running SingleStore version 8.
Why Use Stage
Stage enables you to:
-
Manage files and folders using the Cloud Portal UI, Management API, Notebooks (via the SingleStore Python SDK), and Fusion SQL commands.
-
Load files from a Stage into tables using pipelines,
LOAD DATAcommand, or Cloud Portal UI and notebooks. -
Export query results into a file using the
SELECT .statement.. . INTO STAGE
Manage a Stage
You can manage files and folders in a Stage using any of the following:
Using the Cloud Portal UI
On the Cloud Portal, select Ingestion > Stage in the left navigation pane.
Upload a File
To upload a file in a Stage at the root path (/):
-
Select Ingestion > Stage > Upload File(s).
-
In the Upload File(s) dialog, perform the following:
Select File(s)
Either drag and drop file(s) to the dialog, or select Browse Files to select the files to upload.
Workspace
Select the workspace group associated with the Stage to which the files are uploaded.
Folder
Select one of the following options:
-
No folder: Uploads the file at the Stage root path (
/). -
Select folder: Uploads the file to an existing folder in the Stage; select a folder from the list.
-
Create folder: Uploads the file to a new folder in the Stage; enter a name for the new folder in the New folder name field.
Stage
(Read-only field) Specifies the cloud provider and region where the file is uploaded.
-
-
Select Upload Files to upload the selected file(s) at the specified path in a Stage.
Alternatively, select a folder in Stage, and then select Upload File(s) to directly upload files in this (current) folder.
Create a Folder
Folders help organize and manage files efficiently./):
-
Select Ingestion > Stage > Create Folder.
-
In the Create Folder dialog, perform the following:
Folder Name
Enter a name for the folder.
Workspace
Select the workspace group associated with the Stage where the folder is created.
Stage
(Read-only field) Specifies the cloud provider and region where the folder is created.
-
Select Create Folder.
A folder is now added in the Stage associated with the selected workspace group.
Alternatively, to create a subfolder:
-
Select an existing folder in Stage, and then select Create Folder.
-
Enter a name for the folder in the Folder name field and select Create Folder.
The new folder is created inside the existing folder (as a subfolder) in the Stage associated with the parent folder.
Manage Files and Folders
To perform a specific task, select the ellipsis (three dots) under the Actions column of the file or folder and select the corresponding option from the list.
|
Action |
Instruction |
|---|---|
|
Rename a file or folder |
Select Rename, specify the file or folder name under the Name column, and select the Save rename (✔) icon. |
|
Download a file |
Select Download to download the file. |
|
Load to database |
Select Load Data to ingest the file in a SingleStore database. |
|
Delete a file or folder |
Select Delete, confirm the deletion and then select Delete again to remove the file or folder. Warning Deleting a folder removes the folder and all its contents, including any files and subfolders. |
Using the Management API
Use the Stage path (/v1/stage endpoint) in the Management API to manage files and folders in a Stage.
For example, the following API call lists all the files and folders in the Stage attached to the workspace group with the specified ID:
curl -X 'GET' \'https://api.singlestore.com/v1/stage/68af2f46-0000-1000-9000-3f6f5365d878/fs/' \-H 'accept: application/json'
Using Notebooks or SingleStore Python Client
The SingleStore Python SDK supports the Stage object, which can be used to manage files and folders in a Stage.
For example, the following code snippet uploads a file named data.
from singlestoredb import manage_workspacesmgr = manage_workspaces('access_key_token_for_the_Management_API')wg = mgr.workspace_groups['example-group']wg.stage.upload_file('/filepath/data.csv', '/data.csv')
Using Fusion SQL Commands
Refer to Fusion SQL for the supported operations.
Ingest a File using Stage
Ingest files from Stage into a database using the Cloud Portal, LOAD DATA command, or pipelines.
Using the Cloud Portal
Using the Cloud Portal UI and SingleStore Notebooks, you can ingest Stage files into a SingleStore database attached to the workspace associated with the Stage.
-
Under Stage, select the ellipsis (three dots) in the Actions column of the file to upload, and then select Load To Database.
-
In the Load Data dialog, perform the following:
-
Choose Workspace: Select a cluster.
-
Choose a database: Select a database attached to the workspace.
-
Table: Select an existing table or enter a new table name.
-
-
Select Generate Notebook.
A notebook is created, which contains the instructions and queries required to load the data. Note
You can edit the queries to modify table or column names, apply custom transformations, or make any other adjustments required before loading the data.
-
Select Run > Run All Cells.
Optionally, run each notebook cell individually, in sequence.
The Check that the data has loaded cell verifies if the data has been loaded.
Using the LOAD DATA command
Create a table with a structure that can store data from the file.LOAD DATA syntax to load a file from a stage:
LOAD DATA STAGE 'path_in_stage/filename.extension'INTO TABLE <table_name>[FORMAT {JSON | AVRO | CSV}];
Refer to LOAD DATA for complete syntax and related information.
The following example loads data from a CSV file from a Stage:
LOAD DATA STAGE 'simple.csv'INTO TABLE simple_dataFIELDS TERMINATED BY ','IGNORE 1 LINES;
Note
LOAD DATA STAGE command is not supported in the Shared Edition.
Using Pipelines
Create a table with a structure that can store the data from the file.CREATE PIPELINE syntax to load a file from a Stage:
CREATE PIPELINE <pipeline_name>AS LOAD DATA STAGE <path_in_Stage/filename> { <pipeline_options> }INTO TABLE <table_name>{ <data_format_options> }
Once the table and pipeline are created, start the pipeline.
Here's a sample CREATE PIPELINE statement that loads data from a CSV file:
CREATE PIPELINE dbTest.plTestAS LOAD DATA STAGE 'data.csv'BATCH_INTERVAL 2500SKIP DUPLICATE KEY ERRORSINTO TABLE t1FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\'LINES TERMINATED BY '\n' STARTING BY ''FORMAT CSV;
Export SQL Results to a Stage
SQL results may be exported to a Stage as follows:
SELECT * FROM <table_name> GROUP BY 1 INTO STAGE '<table_results.csv>'FIELDS TERMINATED BY ','LINES TERMINATED BY '\n';
Use the GROUP BY 1 clause to avoid getting multiple files from each leaf node.
Supported Files
The Stage storage service supports the following file formats:
|
CSV |
SQL |
JSON |
|
Parquet |
GZ |
Zstd |
|
Snappy |
Storage Limits
Each Stage can have up to 10GB of storage for free.
Last modified: