Giter Club home page Giter Club logo

serverless-athena's Introduction

Serverless Athena Plugin

Serverless plugin to manage and deploy AWS Athena table

Installation

Install with npm:

npm install --save-dev serverless-athena

And then add the plugin to your serverless.yml file:

plugins:
  - serverless-athena

Alternatively, install with the Serverless plugin command:

sls plugin install -n serverless-athena

Usage

in your serverless.yml

custom:
  athena:
    databases: # list of your dbs
      - name: my-db # required, your database name, do not use an existing database, will be dropped in deployement process
        output: s3://my-athena-output-bucket/ # required, your results bucket
        ddl: $(file(my-database.sql)} # optional, your DDL containing the CREATE DATABASE statement
        sequential: true #optional (default: false), true if you want to create tables sequentially in case of dependencies between tables and views
        tables: # list of yout tables
          - name: mytable # required, table name
            ddl: $(file(my-table.sql)} # required, DDL containing the CREATE TABLE
            keepPartitions: true # force backup and restore partitions
      - name: my-db2 # required, your database name, do not use an existing database, will be dropped in deployement process
        output: s3://my-athena-output-bucket/ # required, your results bucket
        ddl: $(file(my-database.sql)} # optional, your DDL containing the CREATE DATABASE statement
        enabled: false #optional (default: true), plugin will ignore this database creation
        tables: # list of yout tables
          - name: mytable # required, table name
            ddl: $(file(my-table.sql)} # required, DDL containing the CREATE TABLE
            keepPartitions: true # force backup and restore partitions

and

my-table.sql

CREATE EXTERNAL TABLE mytable (
  foo string,
  bar string
)
PARTITIONED BY (dt string)
ROW FORMAT  serde 'org.openx.data.jsonserde.JsonSerDe'
LOCATION 's3://${self:provider.environment.MY_BUCKET}/'
TBLPROPERTIES ('has_encrypted_data'='true');

Workflow

  1. if keepPartition = true backuping partitions
  2. Drop database, therefore, do not use a existing database
  3. Create database
  4. Create tables
  5. Restore partitions if keepPartition = true

serverless-athena's People

Contributors

qwantix avatar

Watchers

James Cloos avatar

Forkers

marlesson

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.