Skip to content

Instantly share code, notes, and snippets.

View jdaarevalo's full-sized avatar

José David Arévalo jdaarevalo

View GitHub Profile
ProcessorFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: processor_lambda.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
Policies:
- AmazonAthenaFullAccess
ProcessedDataS3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Join
- "-"
- - "scatter-gather-processed-data"
- !Select
- 0
- !Split
- "-"
@jdaarevalo
jdaarevalo / template.yaml
Last active April 21, 2023 18:40
create glue table
GlueRawDataNYTimesCovidTable:
Type: 'AWS::Glue::Table'
Properties:
CatalogId: !Ref AWS::AccountId
DatabaseName: !Ref GlueRawDataBase
TableInput:
Description: "Raw Data on COVID-19 cases from NY Times at US state level."
TableType: "EXTERNAL_TABLE"
Retention: 0
Name: covid_nytimes_states
@jdaarevalo
jdaarevalo / query_send_report.py
Last active August 26, 2022 06:52
Lambda function query_send_report
"""
Purpose
Run an Athena query and post in Slack the output location as CSV
Tag the user who does the request
"""
import os
import json
import time
@jdaarevalo
jdaarevalo / last-section-docker-compose.yaml
Last active January 30, 2021 12:14
last-section-docker-compose
...
volumes:
- ./postgres-data:/var/lib/postgresql/data
# copy the sql script to create tables
- ./sql/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql
# copy the sql script to fill tables
- ./sql/fill_tables.sql:/docker-entrypoint-initdb.d/fill_tables.sql
@jdaarevalo
jdaarevalo / six-section-fill_tables.sql
Created January 30, 2021 12:13
six-section-fill_tables
-- Filling of order_status
INSERT INTO order_status
select gen_random_uuid ()
, date_sale + random()* (date_sale + '5 days' - date_sale)
, sale_id
, floor(random() * (current_setting('my.status_names')::int) + 1)::int
from sale;
@jdaarevalo
jdaarevalo / five-section-fill_tables.sql
Created January 30, 2021 12:12
five-section-fill_tables
floor(random() * (current_setting('my.number_of_products')::int) + 1)::int
@jdaarevalo
jdaarevalo / four-section-fill_tables.sql
Created January 30, 2021 12:11
four-section-fill_tables
TO_TIMESTAMP(start_date, 'YYYY-MM-DD HH24:MI:SS') +
random()* (TO_TIMESTAMP(end_date, 'YYYY-MM-DD HH24:MI:SS')
- TO_TIMESTAMP(start_date, 'YYYY-MM-DD HH24:MI:SS'))
@jdaarevalo
jdaarevalo / third-section-fill_tables.sql
Created January 30, 2021 12:10
third-section-fill_tables
CREATE EXTENSION pgcrypto;
--select gen_random_uuid ();
...
-- Filling of sales
INSERT INTO sale;
select gen_random_uuid ()
, round(CAST(float8 (random() * 10000) as numeric), 3)
@jdaarevalo
jdaarevalo / second-section-fill_tables.sql
Created January 30, 2021 12:08
second-section-fill_tables
...
-- Filling of products
INSERT INTO product
select id, concat('Product ', id)
FROM GENERATE_SERIES(1, current_setting('my.number_of_products')::int) as id;
...
...
-- Filling of cities
INSERT INTO city