28 строки
1.1 KiB
SQL
28 строки
1.1 KiB
SQL
-- Legacy wrapper around a function moved to mozfun.
|
|
CREATE OR REPLACE FUNCTION udf.bits28_retention(bits INT64, submission_date DATE) AS (
|
|
mozfun.bits28.retention(bits, submission_date)
|
|
);
|
|
|
|
-- Tests
|
|
WITH test_data AS (
|
|
SELECT
|
|
udf.bits28_retention((1 << 13) | (1 << 10) | 1, DATE('2020-01-28')) AS retention
|
|
)
|
|
SELECT
|
|
assert_equals(DATE('2020-01-28'), retention.day_0.metric_date),
|
|
assert_equals(DATE('2020-01-22'), retention.day_6.metric_date),
|
|
assert_equals(DATE('2020-01-15'), retention.day_13.metric_date),
|
|
assert_equals(DATE('2020-01-08'), retention.day_20.metric_date),
|
|
assert_equals(DATE('2020-01-01'), retention.day_27.metric_date),
|
|
assert_true(retention.day_0.active_on_metric_date),
|
|
assert_false(retention.day_6.active_on_metric_date),
|
|
assert_true(retention.day_13.active_on_metric_date),
|
|
assert_false(retention.day_20.active_on_metric_date),
|
|
assert_false(retention.day_27.active_on_metric_date),
|
|
assert_true(retention.day_13.active_in_week_0),
|
|
assert_true(retention.day_13.active_in_week_0_after_metric_date),
|
|
assert_true(retention.day_13.active_in_week_1),
|
|
assert_false(retention.day_20.active_in_week_0),
|
|
FROM
|
|
test_data
|