Query S3 Data with SQL: Amazon Athena and AWS Glue Tutorial

Analytics Vidhya · Beginner ·🔧 Backend Engineering ·4mo ago

Key Takeaways

Queries S3 data with SQL using Amazon Athena and AWS Glue

Full Transcript

Let's continue our journey on querying data directly with Athena SQL on S3. So I have lot more to share with all of you and let's learn that in the interactive manner. So first of all I am going to use certain terminologies as a part of my upcoming discussion. So that's the reason I have taken all these terminologies here. So we are going to gain an understanding and then we will be moving towards our demonstration. So let's start with the first one. What is data catalog? So if you are going to see this statement anywhere or if you are going to see this terminology anywhere you can say that data catalog is a central meta data repository means it stores information about your data not the data itself. Data will be present in the data store or actual data will be present in the data store. Data catalog will be storing the data definition. Okay. Next service which is a major service we are going to discuss that is Amazon Athena. What Athena is a very popular a very famous service with respect to the data analytics track. So it is a serverless interactive query service that lets you use standard SQL to analyze data directly in Amazon S3. means you no need to move or load the data anywhere. You can directly query the data from the S3 bucket. So from here you can say that your data is actually present in the S3. You are using Athena in order to query that data. But how we query that data soon we are going to understand and learn that. Okay. It uses restro under the hood and integrates with AWS glue data catalog for schema management. Now what is this particular term? So maybe if you have already worked on this term, you will be aware that it is a distributed SQL query engine and it is specifically designed for big data analytics everybody. So I have already taken this terminology also for all of you. And the last one which I will be discussing as a part of this particular discussion right now I'm not done yet. I have lot more to share with all of you as I had mentioned this in the starting only. Glue. Glue is a fully managed serverless data integration service that helps you discover your data, prepare and transform it and load it into data stores. Means if you have to give one one keyword for all these services. Data catalog is a centralized meta data repository. Amazon Athena is the serverless interactive query service. AWS glue is a fully managed data integration service. It is majorly used to design pipelines. And how we are going to use this service as a part of our demo. I'm soon going to help you out with that. So basically I have planned a demo for all of you in different ways. We are going to execute a direct queries. We are going to understand few features of AWS glue and we are also going to explore the Python code. Okay. So first thing let me help you out with this particular diagram. What exactly is happening from where we are starting? We know S3 act as a single source of truth or S3 act as a data lake where you can store your data in a raw format, in native format, in any format. Okay. So here S3 is the location or a data store where your actual data is present. When you are using Athena, okay, or when you are using Amazon Athena console, what exactly you are doing? you are running the SQL queries from the Amazon Athena and this glue data catalog is storing the schemas or the table definition. Okay, so this is exactly what is happening. Athena is referring the schema definition from the glue data catalog which is pointing to the data present in the S3 bucket. So actual storage location is S3 and then other services we are using for the data definition and quering it. Okay, let's start with a very simple demonstration first and then later I am going to take you through certain differences which I have taken for all of you means what can be different Athena scenarios when glue is not used with Athena what are the differences and finally the use cases where you can use different combinations or different scenarios of Athena okay let's start with the first demo everybody What is the first demo we are going to do? We are going to create a S3 bucket and we will be storing a data into S3 bucket. Let me help you out with that. So without any further delay, let's go to the AWS management console. Okay, let me close the additional tabs and I will be starting from here. Okay. So if you are starting for the first time and if you have already watched my previous video lectures, my starting point is console home. So search for S3 in the search bar and you will be navigated to the S3 dashboard. Now from the S3 dashboard what we are going to do our demonstration will be started with creating a S3 bucket. So click on create bucket everybody and I am going to create a general purpose bucket. We have already got a very good understanding on bucket types on different features of Amazon S3 as a part of our previous video lectures. Okay. Just give a globally unique name space. So for example I'm giving a name Athena demo DS bucket something like this. Okay, we can check if this bucket is existing or not. If this bucket could be existing, we will be appending some unique keywords at the end. Okay, test all things with respect to block public access setting. I'm keeping default because anyhow I am going to follow these steps in the same geographical location. So scroll down and say create bucket. Your bucket would be created. Let's wait for the bucket to be created everybody. So this is my Athena demo DS bucket. Now I am going to create a prefix here for the better management okay or for making the search and filteration easy. So click on create folder and let's say I'm going to give a name called sales data because I'm going to use a sample sales CSV file. Click on create folder. Now I had already explained to all of you this create folder is going to create a prefix is going to create a partitions which can be used in order to manage to filter your data easily and which is going to improve the performance at some point of time. Okay. Now I would be using a simple CSV file. I can just show you. Let's say I will be using the sales data dot CSV. The sales data docsv is containing all these information and I have other file also like this is sales dot csv. Okay. So any sample data we can use it search wise. Okay. Let me start with one of the CSV file. So I am going to upload the CSV file into the S3 bucket. Now we have already discussed that we can also use command line interface, management console or programming interface to interact with AWS services. And don't worry, I will be giving you the exposure to all the interfaces as a part of the demonstration. Okay. So let's quickly upload the data inside this particular folder. Okay. So you can do a drag and drop or you can browse for the file. Let me do a drag and drop everybody. Let's say I'm dragging this and dropping it here. It's going to upload a CSV file. So CSV file is uploaded here. Means first part is done. I have a S3 bucket. I have a sample data available in the S3 bucket. Now obviously for a demo purpose I have taken a small data set. You can have a large data set you can take. And just to give you exposure actually I'm going to take one more data set going forward. This is the one. If you want data set with more attributes I can also provide you a link like you can see it is having 266 records. Okay.

Original Description

Unlock the power of your Data Lake! 🚀 In this video, we explore how to query data directly from Amazon S3 using standard SQL with Amazon Athena. Forget the hassle of loading data into a database; learn how a serverless architecture allows you to analyze raw files where they live. What you will learn in this session: ✅ Key Terminologies: Deep dive into Data Catalogs, Amazon Athena, and AWS Glue. ✅ The Athena Architecture: How Athena uses Presto under the hood and integrates with the AWS Glue Data Catalog for schema management. ✅ The "S3 as a Single Source of Truth" Workflow: Understanding the relationship between storage, metadata, and querying. ✅ Hands-on Demo (Step 1): Creating a globally unique S3 bucket, setting up logical prefixes (folders), and uploading sample sales CSV data. Why use Athena & Glue? Athena is a serverless, interactive query service that makes it easy to analyze data in S3. When paired with AWS Glue, you get a fully managed data integration service that discovers and categorizes your data automatically.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Analytics Vidhya · Analytics Vidhya · 0 of 60

← Previous Next →
1 The DataHour: Data Science in Retail
The DataHour: Data Science in Retail
Analytics Vidhya
2 The DataHour: Anomaly detection using NLP and Predictive Modeling
The DataHour: Anomaly detection using NLP and Predictive Modeling
Analytics Vidhya
3 The DataHour: Energy Data Science Project from Scratch
The DataHour: Energy Data Science Project from Scratch
Analytics Vidhya
4 The DataHour: Explainable AI Need and Implementation
The DataHour: Explainable AI Need and Implementation
Analytics Vidhya
5 The DataHour: Google Cloud AI/ML
The DataHour: Google Cloud AI/ML
Analytics Vidhya
6 Prediction to Production in Machine Learning #machinelearning #prediction
Prediction to Production in Machine Learning #machinelearning #prediction
Analytics Vidhya
7 Practical Applications of Data science in Ecommerce
Practical Applications of Data science in Ecommerce
Analytics Vidhya
8 How to tackle Overfitting?#machinelearning #overfitting
How to tackle Overfitting?#machinelearning #overfitting
Analytics Vidhya
9 Building Data Pipelines on GCP #googlecloud #datapipelines #data
Building Data Pipelines on GCP #googlecloud #datapipelines #data
Analytics Vidhya
10 Hands-on with A/B Testing #abtesting #datascience
Hands-on with A/B Testing #abtesting #datascience
Analytics Vidhya
11 Efficient Implementations of Transformers #transformers #cnn  #machinelearning
Efficient Implementations of Transformers #transformers #cnn #machinelearning
Analytics Vidhya
12 Modern Deep Learning Architecture #deeplearning  #architecture #deeplearningtutorial
Modern Deep Learning Architecture #deeplearning #architecture #deeplearningtutorial
Analytics Vidhya
13 Key steps for Designing Artificial Neural Network (ANN) for Image classification #machinelearning
Key steps for Designing Artificial Neural Network (ANN) for Image classification #machinelearning
Analytics Vidhya
14 5 things you should know about Azure SQL #azure #sql #datahour #datascience
5 things you should know about Azure SQL #azure #sql #datahour #datascience
Analytics Vidhya
15 AI & ML in the Automotive Industry #machinelearning #ai
AI & ML in the Automotive Industry #machinelearning #ai
Analytics Vidhya
16 Building Machine Learning Models in BigQuery
Building Machine Learning Models in BigQuery
Analytics Vidhya
17 NLP aspects in Telecommunication Industry
NLP aspects in Telecommunication Industry
Analytics Vidhya
18 Practical Time Series Analysis
Practical Time Series Analysis
Analytics Vidhya
19 Fundamentals of Quantum Computing
Fundamentals of Quantum Computing
Analytics Vidhya
20 A DAY IN THE LIFE of a Data Scientist (From waking up to working on algorithms)
A DAY IN THE LIFE of a Data Scientist (From waking up to working on algorithms)
Analytics Vidhya
21 Classification Machine Learning Model from Scratch
Classification Machine Learning Model from Scratch
Analytics Vidhya
22 Knowledge Graph Solutions using Neo4j
Knowledge Graph Solutions using Neo4j
Analytics Vidhya
23 Model Guesstimation (MLOps)
Model Guesstimation (MLOps)
Analytics Vidhya
24 ETL Pipelines in Google Cloud Platform
ETL Pipelines in Google Cloud Platform
Analytics Vidhya
25 Key steps for Designing Convolutional Neural Network(CNN) for Image Classification
Key steps for Designing Convolutional Neural Network(CNN) for Image Classification
Analytics Vidhya
26 Getting Started with AWS EC2 #amazon #aws
Getting Started with AWS EC2 #amazon #aws
Analytics Vidhya
27 How to Use Azure NLP and Graph Databases for Intelligent Knowledge Mining
How to Use Azure NLP and Graph Databases for Intelligent Knowledge Mining
Analytics Vidhya
28 Certified AI & ML BlackBelt Plus Program #shorts
Certified AI & ML BlackBelt Plus Program #shorts
Analytics Vidhya
29 Visualizing Data using Python #machinelearning #visualization #python
Visualizing Data using Python #machinelearning #visualization #python
Analytics Vidhya
30 DCNN for Machine RUL Prediction using Time-series Data #timeseries #machinelearning #datascience
DCNN for Machine RUL Prediction using Time-series Data #timeseries #machinelearning #datascience
Analytics Vidhya
31 M in ML stands for Math & Magic
M in ML stands for Math & Magic
Analytics Vidhya
32 An Unsupervised ML approach using Clustering
An Unsupervised ML approach using Clustering
Analytics Vidhya
33 Customizing Large Language Models GPT3 for Real-life Use Cases #gpt3 #datascience
Customizing Large Language Models GPT3 for Real-life Use Cases #gpt3 #datascience
Analytics Vidhya
34 Model Parameters vs Hyperparameters - Techniques in ML Engineering #machinelearning
Model Parameters vs Hyperparameters - Techniques in ML Engineering #machinelearning
Analytics Vidhya
35 Practical MLOps #mlops #datascience
Practical MLOps #mlops #datascience
Analytics Vidhya
36 Data Engineering with Databricks #dataengineering #databricks
Data Engineering with Databricks #dataengineering #databricks
Analytics Vidhya
37 Multi-Objective Optimisation
Multi-Objective Optimisation
Analytics Vidhya
38 When Airflow Meets Kubernetes
When Airflow Meets Kubernetes
Analytics Vidhya
39 AI in Banking
AI in Banking
Analytics Vidhya
40 Learn Convolutional Neural Network for Image Recognition
Learn Convolutional Neural Network for Image Recognition
Analytics Vidhya
41 Extracting Value from Data
Extracting Value from Data
Analytics Vidhya
42 How to measure Marketing Channel Effectiveness
How to measure Marketing Channel Effectiveness
Analytics Vidhya
43 Transforming Lives | Data Science Immersive Bootcamp
Transforming Lives | Data Science Immersive Bootcamp
Analytics Vidhya
44 Stock Market Analysis - AI driven approach
Stock Market Analysis - AI driven approach
Analytics Vidhya
45 Become a Data Engineering Professional in 2022 | Future Trends + Skills Required
Become a Data Engineering Professional in 2022 | Future Trends + Skills Required
Analytics Vidhya
46 Ensemble Techniques in Machine Learning #machinelearning #ensemble #datascience
Ensemble Techniques in Machine Learning #machinelearning #ensemble #datascience
Analytics Vidhya
47 The Power of Visualization | Tableau Full Course | Analytics Vidhya
The Power of Visualization | Tableau Full Course | Analytics Vidhya
Analytics Vidhya
48 Demand for Data Engineers is on the Rise | Data Engineer | Analytics Vidhya
Demand for Data Engineers is on the Rise | Data Engineer | Analytics Vidhya
Analytics Vidhya
49 Data Visualization in Data Science | DataHour | Analytics Vidhya
Data Visualization in Data Science | DataHour | Analytics Vidhya
Analytics Vidhya
50 Role of Optimization in Machine Learning & Deep Learning | DataHour | Analytics Vidhya
Role of Optimization in Machine Learning & Deep Learning | DataHour | Analytics Vidhya
Analytics Vidhya
51 Solving any Machine Learning Problem | Approach and Steps Involved
Solving any Machine Learning Problem | Approach and Steps Involved
Analytics Vidhya
52 Topic Modeling Explained with Implementation | Using LDA in Python | DataHour by Arpendu Ganguly
Topic Modeling Explained with Implementation | Using LDA in Python | DataHour by Arpendu Ganguly
Analytics Vidhya
53 Data Engineering in E-Commerce | The Best Case Study
Data Engineering in E-Commerce | The Best Case Study
Analytics Vidhya
54 Introduction to Classification using Azure Machine Learning | DataHour | Analytics Vidhya
Introduction to Classification using Azure Machine Learning | DataHour | Analytics Vidhya
Analytics Vidhya
55 Introduction to Federated Learning | DataHour | Analytics Vidhya
Introduction to Federated Learning | DataHour | Analytics Vidhya
Analytics Vidhya
56 Diffusion Models for Generative Arts | DataHour | Analytics Vidhya
Diffusion Models for Generative Arts | DataHour | Analytics Vidhya
Analytics Vidhya
57 Master Google Analytics in 1 Hour | DataHour | Analytics Vidhya
Master Google Analytics in 1 Hour | DataHour | Analytics Vidhya
Analytics Vidhya
58 Learn Hypothesis Testing | DataHour | Analytics Vidhya
Learn Hypothesis Testing | DataHour | Analytics Vidhya
Analytics Vidhya
59 A Practical Approach to Kaggle Competition | DataHour | Analytics Vidhya
A Practical Approach to Kaggle Competition | DataHour | Analytics Vidhya
Analytics Vidhya
60 Making AI work for Business | DataHour | Analytics Vidhya
Making AI work for Business | DataHour | Analytics Vidhya
Analytics Vidhya

Related Reads

📰
What Is a Simple Request and When Does the Browser Send a Preflight Request?
Learn when browsers send preflight requests and how to handle them in your web development workflow
Dev.to · Alireza Hassankhani
📰
How to learn the basics of c++?
Learn C++ basics in a month with free resources and a solid study plan
Reddit r/learnprogramming
📰
Composer Isn’t Just a Dependency Manager — It’s the Backbone of Modern PHP Development
Learn how Composer is the backbone of modern PHP development and why it's more than just a dependency manager
Medium · Programming
📰
How a frustrating school project led me to build my first CLI tool.
Learn how a frustrating school project inspired the creation of a first CLI tool and discover the process of building a command-line interface using JavaScript
Medium · JavaScript
Up next
Indian Express Editorial Analysis by Chandan Sharma - 1 JULY 2026 | UPSC Current Affairs 2026
StudyIQ IAS
Watch →