Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Amazon Athena and Tableau: Serverless Interactive Query Service and BI

DZone's Guide to

Amazon Athena and Tableau: Serverless Interactive Query Service and BI

Learn how Athena can process both structured and semi-structured data in different file formats, generate reports in connection with BI tools, and more.

Free Resource

See how the beta release of Kubernetes on DC/OS 1.10 delivers the most robust platform for building & operating data-intensive, containerized apps. Register now for tech preview.

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.

Prerequisites

Sign into AWS console. Then, create your own S3 bucket in S3 to upload data as shown below:

select

select

Lastly, create a 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, scroll down to the References section.

Columns:

  • Step: Maps a unit of time in the real world; in this use case, one step represents one hour of time.
  • Type: Diverse types of payments (i.e. CASH_IN, CASH_OUT, DEBIT, PAYMENT, and 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 units 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, but especially in financial institutions such as banks, credit unions, and so on. As mobile transactions in the financial industry have increased in recent years, it is highly challenging to secure the data in the mobile platform. In this use case, let's discuss finding and managing malicious behavior during mobile transactions.

In this blog, let's 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 the configuration 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:

selectThe data is queried as follows:

select

Connecting Athena With BI Tools (Tableau 10.3)

To connect Athena with Tableau, perform the following:

  • Download Athena connector from this path.
  • Place the connector in the 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

select

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

select

Data Visualization

A 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

References

New Mesosphere DC/OS 1.10: Production-proven reliability, security & scalability for fast-data, modern apps. Register now for a live demo.

Topics:
athena ,tableau ,business inteligence ,big data ,tutorial ,data analytics ,data visualization ,amazon s3 ,serverless

Published at DZone with permission of Rathnadevi Manivannan. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}