Skip to content

Instantly share code, notes, and snippets.

@mushkevych
Last active November 2, 2016 03:44
Show Gist options
  • Save mushkevych/f92f685295b4dbba8e97340a4aecde63 to your computer and use it in GitHub Desktop.
Save mushkevych/f92f685295b4dbba8e97340a4aecde63 to your computer and use it in GitHub Desktop.
sdpl_snippets
!DataRepository
db: mydb
host: host.the_company.xyz
kwargs: {}
name: repo_a
password: the_password
port: '6789'
user: the_user
A = LOAD SCHEMA 'schema_a.yaml' VERSION 1 ;
``` -- vanilla Pig
X = LOAD 'data' AS (``` EXPAND SCHEMA A; ```);
STORE X INTO 'db://db_connection_string';
```
A = {
"a" : {data_type: CHARARRAY, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, version: 1},
"aa" : {data_type: CHARARRAY, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, version: 1},
"aaa" : {data_type: CHARARRAY, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, version: 1}
}
B = {
"b" : {data_type: INTEGER, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, version: 1},
"bb" : {data_type: INTEGER, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, version: 1},
"bbb" : {data_type: INTEGER, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, version: 1}
}
!Schema
fields:
- !Field {data_type: CHARARRAY, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, name: a, version: 1}
- !Field {data_type: CHARARRAY, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, name: aa, version: 1}
- !Field {data_type: CHARARRAY, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, name: aaa, version: 1}
- !Field {data_type: BOOLEAN, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, name: column, version: 1}
- !Field {data_type: BOOLEAN, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, name: another_column, version: 1}
- !Field {data_type: BOOLEAN, default: null, is_nullable: null, is_primary_key: null, is_unique: null, max_length: null, name: yet_another_column, version: 1}
A = LOAD SCHEMA 'A.yaml' VERSION 1;
B = LOAD SCHEMA 'B.yaml' VERSION 1;
Z = SCHEMA PROJECTION (A.*, B.b, -A.aaa);
A = LOAD TABLE 'table_a' FROM 'repo_a.yaml' WITH SCHEMA 'schema_a.yaml' VERSION 1 ;
B = LOAD TABLE 'table_b' FROM 'repo_a.yaml' WITH SCHEMA 'schema_b.yaml' VERSION 1;
C = LOAD TABLE 'table_c' FROM 'repo_a.yaml' WITH SCHEMA 'schema_c.yaml' VERSION 1;
D = JOIN A BY (A.a), B BY (B.b)
WITH SCHEMA PROJECTION (A.*, B.column AS new_column);
E = JOIN C BY (C.c), D BY (D.new_column)
WITH SCHEMA PROJECTION (C.*, D.new_column, D.column AS renamed_column);
STORE D INTO TABLE 'table_d' FROM 'repo_a.yaml';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment