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
WITH | |
base AS ( | |
SELECT | |
SAFE_CAST ( | |
JSON_EXTRACT_SCALAR (payload, '$.timestamp') AS timestamp | |
) AS event_time, | |
JSON_EXTRACT_SCALAR (payload, '$.action') AS action_type, | |
JSON_EXTRACT_SCALAR (payload, '$.actor_id') AS actor_id, | |
JSON_EXTRACT_SCALAR (payload, '$.actor_username') AS actor_username, | |
FROM |
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
CREATE OR REPLACE FUNCTION _wstd_state(state numeric[3], val numeric, weight numeric) | |
RETURNS numeric[3] AS $$ | |
DECLARE | |
s_n_1 CONSTANT numeric NOT NULL := state[1]; | |
mu_n_1 CONSTANT numeric NOT NULL := state[2]; | |
w_n_1 CONSTANT numeric NOT NULL := state[3]; | |
s_n numeric; | |
mu_n numeric; | |
w_n numeric; | |
BEGIN |
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
import contextlib | |
import tempfile | |
import random | |
def two_pass_shuffle(input_files, output_files, temp_file_count, header_lines=0): | |
""" | |
two_pass_shuffle | |
Suffle data larger that can be shuffled in memory. | |
Implementation based on: |