Giter Club home page Giter Club logo

spark-athena's Introduction

AWS Athena Data Source for Apache Spark

This library provides support for reading an Amazon Athena table with Apache Spark via Athena JDBC Driver.

I developed this library for the following reasons:

Apache Spark is implemented to use PreparedStatement when reading data through JDBC. However, because Athena JDBC Driver provided by AWS only implements Statement of JDBC Driver Spec and PreparedStatement is not implemented, Apache Spark can not read Athena data through JDBC.

So I refer to the JDBC data source implementation code in spark-sql and change it to call Statement of Athena JDBC Driver so that Apache Spark can read Athena data.

Table of Contents

DataFrame Usage

You can register a Athena table and run SQL queries against it, or query with the Apache Spark SQL DSL.

import io.github.tmheo.spark.athena._

// Read a table from current region with default s3 staging directory.
val users = spark.read.athena("(select * from users)")

// Read a table from current region with s3 staging directory.
val users2 = spark.read.athena("users", "s3://staging_dir")

// Read a table from another region with s3 staging directory.
val users3 = spark.read.athena("users", "us-east-1", "s3://staging_dir")

Configuration

Option Description
dbtable Athena Table or SQL Query
region AWS Region. Default value is current region
s3_staging_dir The Amazon S3 location to which your query output is written. Default value is s3://aws-athena-query-results-${accountNumber}-${region}/
user AWS Access Key Id. If you do not specify user, password, the library will try to use InstanceProfileCredentialsProvider.
password AWS Secret Access Key. If you do not specify user, password, the library will try to use InstanceProfileCredentialsProvider.

spark-athena's People

Contributors

tmheo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.