SELECT
query directly to an Amazon S3 location using COPY TO. This method is more flexible and efficient than downloading query results manually from the Firebolt Workspace, making it ideal for data sharing, integration, and archival.
How to export data
The following code example usesCOPY TO
to export the result of a SELECT
query from my_table
to a specified Amazon S3 bucket in CSV format using the provided AWS credentials:
Choose the right export format
Format | Best For | Characteristics | Recommended Use |
---|---|---|---|
CSV (Comma-Separated) | General data exchange, spreadsheets, SQL. | Simple, widely supported, and easy to read. | Best for spreadsheets, databases, or general data exchange. |
TSV (Tab-Separated) | Structured text data. | Like CSV, but uses tabs instead of commas. | Best for Excel, databases, or general data exchange. |
JSON | APIs, web applications, NoSQL databases. | Flexible, human-readable, and supports nested data. | Best for web apps, APIs, or NoSQL integrations. |
PARQUET | Big data processing, analytics workloads. | Compressed, columnar, and optimized for querying. | Ideal for analytics, performance-sensitive workloads, and large datasets. |
Examples
Export data in CSV format Use CSV when you need a simple, widely supported format for spreadsheets, relational databases, or data exchange. The following code example exportsuser_id
, event_type
, and timestamp
data and headers from the user_events
table to a CSV file in an Amazon S3 bucket:
sales_data
table to an Amazon S3 bucket in Parquet format using the provided AWS credentials:
order_id
and order_details
from the orders
table to an Amazon S3 bucket in JSON format using the provided AWS credentials:
name
, age
, and city
from the customers
table to an Amazon S3 bucket in TSV format using the provided AWS credentials:
Additional Considerations
Performance tips- Export only required columns and use filters to reduce data volume
- Ensure proper permissions are set on your S3 bucket
- Always use secure AWS credentials.
- Use IAM roles instead setting credentials directly in the code for better security.