Table of Content
- 1 Overview
- 2 Pre-requisites
- 3 Dataset Description
- 4 Use Cases
- 5 Connecting Athena with JDBC SQL Workbench Driver
- 6 Connecting Athena with BI Tools (Tableau 10.3)
- 7 Data Visualization
- 7.1 Total Amount Based on Type and IsFraud Flag
- 7.2 New Balance and Old Balance Based on Type
- 7.3 Total Amount Based on Type and Fraudulent Activities
- 7.4 Minimum New Balance and Minimum Old Balance Based on Type
- 7.5 Count of Steps for Fraudulent Types of Transactions
- 7.6 Percentage of Steps for Fraudulent Type of Activities
- 8 Conclusion
- 9 References
Amazon Athena, a serverless query service in Amazon Simple Storage Service (S3) and a pay per service, is used to easily analyze data using standard SQL in S3. It has a very high query performance even for huge datasets and complex queries.
Athena can process both structured and semi-structured data in different file formats such as CSV, JSON, Parquet, and ORC. It can be used to generate reports in connection with BI tools. It uses HIVE for creating database and tables. As it has metastore, it can be used with Hadoop, Spark, and Presto.
- Sign into AWS console.
- Create your own S3 bucket in S3 to upload data as shown below:
- Create database and tables in Athena to query the data.
A sample dataset, containing bank transaction data of a customer, is used in this use case. For sample dataset, please consider Reference section.
- Step – Maps a unit of time in the real world. In this use case, 1 step represents 1 hour of time.
- Type – Diverse types of payments (CASH_IN, CASH_OUT, DEBIT, PAYMENT, TRANSFER).
- Amount – Amount of transaction in local currency.
- nameOrig – Customer who started the transaction.
- oldbalanceOrg – Initial balance before the transaction.
- newbalanceOrig – New balance after the transaction.
- NameDest – Customer who is the recipient of the transaction.
- OldbalanceDest – Initial balance recipient before the transaction.
- NewbalanceDest – New balance recipient after the transaction.
- IsFraud – Transactions made by the fraudulent agents inside the simulation.
- IsFlaggedFraud – An illegal attempt in this dataset is an attempt to transfer more than 200.000 in a single transaction.
Note: There is no information for customers name starting with M (Merchants).
Data security plays a significant role in almost all sectors especially in financial institutions such as banks, credit unions, and so on. As mobile transactions in the financial industry have increased during recent days, it is highly challenging to secure the data in the mobile platform. In this use case, let us discuss on finding and managing malicious behavior during mobile transactions.
In this blog, let us discuss the below use cases:
- Connect Athena with JDBC SQL Workbench Driver
- Connect Athena with BI Tools (Tableau 10.3)
Connecting Athena with JDBC SQL Workbench Driver
You can query data from AWS console by connecting JDBC SQL workbench with Athena.
- Download Athena jar from the following path:
- Ensure the system is configured with Java 1.8 version.
- Download SQL workbench if needed from the following path:
To connect Athena with JDBC driver using SQL workbench, perform the following:
- In SQL workbench, choose File –> Manage drivers.
- Perform configuration as shown in the below diagram:
- Add a new driver connection by configuring user name and password as your AWS access key and secret key, respectively.
- Configure your s3_staging_dir in extended properties to save your executed queries in your S3 bucket.
- Create a table with SQL workbench.
The table structure is as follows:
The data visualization in table format is as follows:
The data is queried as follows:
Connecting Athena with BI Tools (Tableau 10.3)
To connect Athena with Tableau, perform the following:
- Download Athena connector from the following path:
- Place the connector in the following location:
C:\Program Files\Tableau\Drivers directory.
- In Tableau, configure the following:
- Server – atena.region.com
- Port – 443
- S3 Staging Directory – s3://yourbucketname/query_save_folder
- Access Key ID
- Secret Access Key
On successfully creating connections, Athena databases will be listed out as shown in the below diagram:
Few data visualizations are as follows:
Total Amount Based on Type and IsFraud Flag
New Balance and Old Balance Based on Type
Total Amount Based on Type and Fraudulent Activities
Minimum New Balance and Minimum Old Balance Based on Type
Count of Steps for Fraudulent Types of Transactions
Percentage of Steps for Fraudulent Type of Activities
Athena very fastly queries data directly from Amazon S3 without any ETL. As it is a pay per service, 1 TB charges $5. As it possesses performance improving techniques such as partitioning, compressing, and so on, it supports accessing huge datasets.
- Amazon Athena Documentation:
- Delete Replicas and Switch to Single-AZ When Stopping RDS Instances:
- Common AWS Athena and Tableau errors and what to do about them: