Skip to content

Commit ea3be2e

Browse files
authored
Update invoke_purchase_propensity_training_preparation.sqlx
1 parent 2b24996 commit ea3be2e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

sql/query/invoke_purchase_propensity_training_preparation.sqlx

+8-7
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@ SET validation_split_end_number = {{validation_split_end_number}};
5454
SET purchasers = (SELECT COUNT(DISTINCT user_pseudo_id)
5555
FROM `{{mds_project_id}}.{{mds_dataset}}.event`
5656
WHERE event_name = 'purchase' AND
57-
event_date BETWEEN train_start_date AND train_end_date
57+
event_date BETWEEN min_date AND max_date
5858
);
5959

60-
-- If there are purchasers no changes to the train_start_date and train_end_date
61-
-- Else, expand the interval, hopefully a purchaser will be in the interval
62-
IF purchasers > 0 THEN
63-
SET train_start_date = GREATEST(train_start_date, min_date);
64-
SET train_end_date = LEAST(train_end_date, max_date);
65-
ELSE
60+
-- Setting Training Dates
61+
-- If there are churners in the training set, then keep the calculated dates, or else set
62+
-- the start and end dates to a fixed interval preventing `train_start_date` and `train_end_date` from being NULL.
63+
IF churners > 0 THEN
6664
SET train_start_date = min_date;
6765
SET train_end_date = max_date;
66+
ELSE
67+
SET train_start_date = DATE '2000-01-01';
68+
SET train_end_date = DATE '2024-12-01';
6869
END IF;
6970

7071
-- Finally, the script calls a stored procedure, passing the adjusted training dates and split numbers as arguments. This stored procedure

0 commit comments

Comments
 (0)