Get started with Amazon S3 Select

Amazon S3 Select is a feature of Amazon Simple Storage Service (Amazon S3) that allows you to retrieve only a subset of data from an object in S3. This can be particularly useful when dealing with large amounts of data stored in S3, as it can significantly reduce the amount of data that needs to be loaded and processed.

Here are the key aspects of Amazon S3 Select:

  1. Efficient Data Retrieval: Instead of retrieving the entire object, S3 Select enables you to retrieve only the data you need from an S3 object. This is done by running simple SQL-like queries on the object.

  2. Supported Formats: S3 Select works with objects stored in CSV, JSON, and Parquet formats. It also works with objects that are compressed with GZIP or BZIP2 (for CSV and JSON objects only), and server-side encrypted objects. This allows you to interact with various types of structured and semi-structured data.

  3. Cost and Time Effective: By retrieving only the necessary data, you can reduce the amount of data transferred from Amazon S3 to your application, which can lower the cost and decrease the response time.

  4. Integration with AWS Services: S3 Select can be used in conjunction with other AWS services like Amazon Athena, Amazon Redshift Spectrum, and AWS Lambda for more complex data processing and analytics tasks.

  5. Use Cases: It's particularly useful in scenarios where you need to quickly access and analyze large amounts of data without the need to download entire files. Common use cases include log file analysis, data exploration, and filtering specific data from large datasets.

  6. SQL-like Query Language: The query language used in S3 Select is SQL-like, which makes it familiar and easy to use for those who already have SQL knowledge.

  7. API Integration: S3 Select can be accessed using the AWS SDKs or through the AWS CLI, making it easy to integrate with existing applications.

In summary, Amazon S3 Select enhances the way you can interact with data stored in S3, making it more efficient to perform queries and retrieve specific data without the need to process entire files. This can lead to significant performance improvements and cost savings, especially when working with large datasets.

Tutorial: Use Amazon S3 Select to filter data from JSON object file

To get hands-on experience with Amazon S3 Select, you'll need to follow a series of steps that involve setting up an AWS account, uploading a file to an S3 bucket, and then using S3 Select to query that file.


  • An AWS account. If you don’t have one, you can sign up for a free tier account on the AWS website.

  • AWS Command Line Interface (CLI) installed and configured with your AWS credentials. You can find instructions on installing and configuring the AWS CLI in the AWS documentation.


1. Create an S3 Bucket

  • Log in to the AWS Management Console.

  • Navigate to the S3 dashboard and click Create bucket.

  • Give your bucket a unique name and select a region.

  • Click Create.

2. Upload a File

  • Prepare a CSV, JSON, or Parquet file that you want to query. For simplicity, let's assume a JSON file with some structured data.

    Here's an example of what the JSON file content could look like:

      {"Name": "Alice", "Age": 30, "City": "New York"}
      {"Name": "Bob", "Age": 25, "City": "Los Angeles"}
      {"Name": "Charlie", "Age": 35, "City": "Chicago"}
  • Navigate to your newly created bucket in the S3 dashboard.

  • Click Upload and select your file.

3. Query Using S3 Select

  • Open a command prompt or terminal.

  • Use the AWS CLI to run an S3 Select command. Here’s an example query syntax:

      aws s3api select-object-content \
          --bucket your-bucket-name \
          --key your-file-name.json \
          --expression "SELECT * FROM s3object[*] s WHERE s.Age > 29" \
          --expression-type 'SQL' \
          --input-serialization '{"JSON": {"Type": "LINES"}}' \
          --output-serialization '{"JSON": {}}' \

    Replace your-bucket-name with the name of your bucket, and your-file-name.json with the name of your file. This command queries a JSON file where it selects rows where the age is greater than 29.

  • Execute the command. The results will be saved in output.json.

4. Analyze the Results

  • Open output.json to view the results of your query.

5. Clean Up

  • To avoid incurring charges, you can delete the S3 bucket and the file after you're done experimenting.

Additional Notes

  • The above example uses a simple SQL query for demonstration purposes. You can construct more complex queries based on your file structure and requirements.

  • Always ensure that your S3 buckets and files have the appropriate permissions set for security reasons. Avoid using public access unless absolutely necessary.

  • The AWS CLI provides a versatile way to interact with S3 Select, but you can also use AWS SDKs for various programming languages to integrate S3 Select into your applications. For more information, see SQL reference for Amazon S3 Select

This tutorial provides a basic introduction to using S3 Select. As you become more familiar with it, you can explore more advanced features and use cases.


  1. Filtering and retrieving data using Amazon S3 Select

  2. Examples of using Amazon S3 Select on objects

  3. S3 Select and Glacier Select – Retrieving Subsets of Objects

  4. SELECT command

  5. SQL reference for Amazon S3 Select