Skip to content

Instantly share code, notes, and snippets.

@oascofare
oascofare / dim_calendar.hql
Created March 30, 2020 22:49 — forked from PeterAttardo/dim_calendar.hql
Create calendar dimension table in hive query language (HQL)
set hivevar:start_date=0000-01-01;
set hivevar:days=1000000;
set hivevar:table_name=[INSERT YOUR TABLE NAME HERE];
-- If you are running a version of HIVE prior to 1.2, comment out all uses of date_format() and uncomment the lines below for equivalent functionality
CREATE TABLE IF NOT EXISTS ${table_name} AS
WITH dates AS (
SELECT date_add("${start_date}", a.pos) as date