Amazon Athena & Tableau – Serverless Interactive Query Service and Business Intelligence (BI)

Amazon Athena & Tableau – Serverless Interactive Query Service and Business Intelligence (BI)

Overview

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.

Pre-requisites

  • Sign into AWS console.
  • Create your own S3 bucket in S3 to upload data as shown below:

select

select

  • Create database and tables in Athena to query the data.

select

Dataset Description

A sample dataset, containing bank transaction data of a customer, is used in this use case. For sample dataset, please consider Reference section.

Columns

  • 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).

Use Cases

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.

Pre-requisites:

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:

select

  • 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.

select

  • Create a table with SQL workbench.

select

The table structure is as follows:

select

The data visualization in table format is as follows:

select

The data is queried as follows:

select

Connecting Athena with BI Tools (Tableau 10.3)

To connect Athena with Tableau, perform the following:

select

On successfully creating connections, Athena databases will be listed out as shown in the below diagram:

select

Data Visualization

Few data visualizations are as follows:

Total Amount Based on Type and IsFraud Flag

select

New Balance and Old Balance Based on Type

select

Total Amount Based on Type and Fraudulent Activities

select

Minimum New Balance and Minimum Old Balance Based on Type

select

Count of Steps for Fraudulent Types of Transactions

select

Percentage of Steps for Fraudulent Type of Activities

select

Conclusion

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.

References

328 Views 1 Views Today