Show Menu
Cheatography

Hocon & SQL Cheat Sheet Cheat Sheet (DRAFT) by

Hocon & SQL Cheat Sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Link to Docume­ntation

SQL Formatting

Statement
Format
Example
SQL Statement
UPPERCASE
SELECT col AS column
Tables
Views
Functions
snake_case
CREATE TABLE test_table
Indent­ation
Tables
Columns
SELECT 
col,
col2,
col3
FROM
table_name
Commas
Trailing

Hocon Formatting

Operation
Do
Don't
Interp­olated Column Names
Keep Within Same File
pipeli­ne.c­onf: 
sql_columns="col1, col2, col3"
SELECT
{sql_c­olumns}
FROM
sql_co­lum­ns.c­onf: 
sql_co­lum­ns=­"­col1, col2, col3"
pipeline.conf: SELECT
{sql_c­olumns}
FROM
Concat­ination of Columns
pipeli­ne.c­onf: 
sql_columns="col1, col2, col3, col4"

SELECT
{sql_c­olumns}
FROM
pipeli­ne.c­onf: 
sql_columns_all={
{sql_columns1},
{sql_columns2}}

SELECT
{sql_columns_all}
FROM
Margin & Indents
sql_query: """
SELECT
CREATEDT AS created_date
FROM
table
"""
sql_query: "­SELECT col1 AS column FROM table"

Miscel­laneous

Comments
Make comments regarding business logic (GROUP BY, MAX(x), x*100
Example:
SELECT
x_type AS method --Keep for switch­board compat­ibility
Renamings
Don't Add Unders­cores to Raw Table Names
Example:
SELECT
DEPART­MEN­TDESC AS depart­men­t_desc --Keep for switch­board compat­ibility
 

SQL Conven­tions

Operation
Do
Don't
SELECT
Explicit
SELECT
column1,
column2
FROM
table_name
SELECT * 
FROM
table_name
JOIN
Explicit with Alias
SELECT
table_­nam­e.c­olumn1,
table_name.2column2
FROM
catalo­g.s­che­ma.t­ab­le_name AS table_name
LEFT JOIN
catalo­g.s­che­ma.t­ab­le_­name2 AS table_name2
ON table_­nam­e2.site = table_­nam­e.site
SELECT
column1,
column2
FROM
catalo­g.s­che­ma.t­ab­le_name
JOIN
catalo­g.s­che­ma.t­ab­le_­name2
ON catalo­g.s­che­ma.t­ab­le_­nam­e2.site = catalo­g.s­che­ma.t­ab­le_­nam­e.site