This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Generates a numbers table | |
-- Works on Azure SQL, BigQuery, Postgres, Redshift, and Snowflake | |
-- | |
-- empty_rows generates 36 rows with a single column | |
-- the FROM statements are cross joins -- each multiplies the number of rows by 36 | |
-- row_number gives us our desired output | |
-- going all the way to e is 36^5 = 60M rows | |
WITH empty_rows AS ( | |
SELECT 1 AS n UNION ALL SELECT 1 AS n UNION ALL SELECT 1 AS n UNION ALL SELECT 1 AS n UNION ALL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- DateDiff function that returns the difference between two timestamps in the given date_part (weeks, months, etc) as an integer | |
-- This behaves like the DateDiff function in warehouses like Redshift and Snowflake, which count the boundaries between date_parts | |
CREATE OR REPLACE FUNCTION datediff (date_part VARCHAR(30), start_t TIMESTAMP, end_t TIMESTAMP) | |
RETURNS INT AS $diff$ | |
DECLARE | |
years INT = 0; | |
days INT = 0; | |
hours INT = 0; | |
minutes INT = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Generates timestamps that follow a function: y = r^x | |
with | |
quickly_increasing_timestamps as ( | |
select | |
'2020-01-01'::timestamp as time_start, | |
sysdate as time_end, | |
date_diff('minute', time_start, time_end) as time_span_minutes, | |
random() as x, -- generate a random value from 0 to 1 for x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Generates timestamps that follow a function: y = r^x | |
with | |
increasing_timestamps as ( | |
select | |
'2020-01-01'::timestamp as time_start, | |
sysdate as time_end, | |
date_diff('minute', time_start, time_end) as time_span_minutes, | |
random() as x, -- generate a random value from 0 to 1 for x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- generates timestamps randomly between the start and end times | |
with | |
random_timestamps as ( | |
select | |
-- some 'variables' just to make things clear | |
'2021-01-01'::timestamp as time_start, | |
sysdate as time_end, | |
date_diff('minute', time_start, time_end) as time_span_minutes, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Generates a list of sequential integers | |
-- How it works: | |
-- empty_rows is 36 rows of 1 | |
-- cross join with itself any number of times as needed | |
-- a -> 36 rows | |
-- a, b -> 36*36 rows | |
-- a, b, c -> 36*36*36 rows | |
-- row_number gives us our integer for the table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 10M numbers for Azure SQL Database | |
WITH digit (d) AS | |
( | |
select 0 as d union all | |
select 1 union all select 2 union all select 3 union all | |
select 4 union all select 5 union all select 6 union all | |
select 7 union all select 8 union all select 9 | |
), | |
seq (num) as ( | |
select top 1000000000000 -- top is needed for order by |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- generate 10M numbers on Redshift | |
with digit as ( | |
select 0 as d union all | |
select 1 union all select 2 union all select 3 union all | |
select 4 union all select 5 union all select 6 union all | |
select 7 union all select 8 union all select 9 | |
), | |
seq as ( | |
select a.d + (10 * b.d) + (100 * c.d) + (1000 * d.d) + (10000 * e.d) + (100000 * f.d) + (1000000 * g.d) as num | |
from digit a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/Cedric/Code/SocialWeb/app/services/events/events.slim: | |
9 |{{rsvpLanguage}} | |
10 .rsvp.styleLargeBC ng-if="!event.isPublic && !$root.user.isLoggedIn()" | |
11: a.anywhereCTA.styleBadass href="https://signup.wework.com" target="_blank" | |
12 |Become a member and gain access to this event and hundreds more like it. | |
13 .nonMemberAttendanceBlock ng-if="!$root.user.isLoggedIn() && event.isPublic" | |
/Users/Cedric/Code/SocialWeb/app/services/login/login.slim: | |
31 .not-member.styleLargeBC | |
32 | Not a member yet? |