Я настроил код для загрузки данных из Google Analytics из необработанной таблицы GA в адаптированную таблицу, которая предлагает больше возможностей для анализа. Каким-то образом Задача не выполняется в течение установленного времени 3600 секунд. Таким образом, задача отменяется и данные не загружаются.
"Заявление достигло своего заявления или истекло время ожидания хранилища 3600 секунд и было отменено." Затем я загружаю его вручную, используя фиксированный пункт: WHERE gae."DAY"='2020-03-31'
вместо WHERE gae."DAY">=CuRRENT_DATE-1
. Это занимает еще много времени, но работает в конце.
Как я могу сделать этот запрос быстрее? Или в любом случае, решите мою проблему.
CREATE OR REPLACE TASK dm."Website"."x009_002_all_GA_events"
WAREHOUSE = marketing_wh
SCHEDULE = 'USING CRON 26 5 * * * Europe/Berlin'
AS
merge into DM."Website".ALL_GA_EVENTS_CLEAN target --DM."Website".ALL_GA_EVENTS target
using (
SELECT
GAEVENTACTION AS GAEVENTACTION,
GAEVENTCATEGORY AS GAEVENTCATEGORY,
"DAY" AS Datum,
DEVICE_TYPE AS Device,
EVENT_COUNT AS EventCount,
GAUNIQUEEVENTS AS Uniqueevents,
EVENT_VALUE AS eventvalue,
LABELS AS labelz,
URL AS urlz,
--split_part(LABELS,'/_',2) AS "HITSTAMP",
CASE WHEN split_part(LABELS,'/_',2) IS NOT NULL THEN TRY_CAST(split_part(LABELS,'/_',2) AS timestamp) ELSE NULL END AS "HITSTAMP",
split_part(LABELS,'/_',3) AS EVENT_INFO,
split_part(LABELS,'/_',1) AS "SESSIONID",
CASE
WHEN CONTAINS (URL, '/checkout/')=TRUE THEN split_part(URL,'/',3)
WHEN CONTAINS (URL, '/auto/')=TRUE THEN split_part(split_part(URL,'/',3),'?',1)
WHEN CONTAINS (URL, '/angebote/')=TRUE THEN split_part(URL,'/',3)
ELSE 'no vehicle'
END AS vehicleID,
rank() over (partition BY "SESSIONID" order by "HITSTAMP") as "RANK",
CASE
WHEN (GAEVENTACTION= ('pdp_flash_offer_request' )) THEN
CASE WHEN split_part(LABELS,'/_',2)=(SELECT min(split_part(t2.LABELS,'/_',2))
FROM "DL_Datatap"."PUBLIC"."GA_all_events" t2
WHERE split_part(t2.LABELS,'/_',1)=split_part(gae.LABELS,'/_',1) AND gae.GAEVENTACTION=t2.GAEVENTACTION)
THEN TRUE
ELSE FALSE
END
WHEN (GAEVENTACTION= ('chat_started')) THEN
CASE WHEN split_part(LABELS,'/_',2)=(SELECT min(split_part(t2.LABELS,'/_',2))
FROM "DL_Datatap"."PUBLIC"."GA_all_events" t2
WHERE split_part(t2.LABELS,'/_',1)=split_part(gae.LABELS,'/_',1) AND gae.GAEVENTACTION=t2.GAEVENTACTION)
THEN TRUE
ELSE FALSE
END
WHEN (GAEVENTACTION= ('Direct_checkout_send')) THEN
CASE WHEN split_part(LABELS,'/_',2)=(SELECT min(split_part(t2.LABELS,'/_',2))
FROM "DL_Datatap"."PUBLIC"."GA_all_events" t2
WHERE split_part(t2.LABELS,'/_',1)=split_part(gae.LABELS,'/_',1) AND gae.GAEVENTACTION=t2.GAEVENTACTION)
THEN TRUE
ELSE FALSE
END
WHEN (GAEVENTACTION= ('pdp_offer_request')) THEN
CASE WHEN split_part(LABELS,'/_',2)=(SELECT min(split_part(t2.LABELS,'/_',2))
FROM "DL_Datatap"."PUBLIC"."GA_all_events" t2
WHERE split_part(t2.LABELS,'/_',1)=split_part(gae.LABELS,'/_',1) AND gae.GAEVENTACTION=t2.GAEVENTACTION)
THEN TRUE
ELSE FALSE
END
WHEN (GAEVENTACTION= ('agent-requested')) THEN
CASE WHEN split_part(LABELS,'/_',2)=(SELECT min(split_part(t2.LABELS,'/_',2))
FROM "DL_Datatap"."PUBLIC"."GA_all_events" t2
WHERE split_part(t2.LABELS,'/_',1)=split_part(gae.LABELS,'/_',1) AND gae.GAEVENTACTION=t2.GAEVENTACTION)
THEN TRUE
ELSE FALSE
END
WHEN (GAEVENTACTION= ('SERP_softlead_send')) THEN
CASE WHEN split_part(LABELS,'/_',2)=(SELECT min(split_part(t2.LABELS,'/_',2))
FROM "DL_Datatap"."PUBLIC"."GA_all_events" t2
WHERE split_part(t2.LABELS,'/_',1)=split_part(gae.LABELS,'/_',1) AND gae.GAEVENTACTION=t2.GAEVENTACTION)
THEN TRUE
ELSE FALSE
END
ELSE False
END AS "GOAL_EVENT"
FROM "DL_Datatap"."PUBLIC"."GA_all_events" gae
---WHERE gae."DAY"='2020-03-31'
WHERE gae."DAY">=CuRRENT_DATE-1
) SOURCE
ON target.SESSIONID=SOURCE."SESSIONID" AND target.HITSTAMP=SOURCE."HITSTAMP" AND target.EVENT_ACTION=SOURCE.GAEVENTACTION AND target."Date"=SOURCE.Datum
when NOT matched then INSERT (EVENT_ACTION, EVENT_CATEGORY, "Date", DEVICE, TOTAL_EVENTS, UNIQUE_EVENTS, EVENT_VALUE, EVENT_LABEL, URL, HITSTAMP, EVENT_INFO, SESSIONID, VEHICLEID, EVENT_SEQUENCE, GOAL_EVENT)
VALUES (SOURCE.GAEVENTACTION, SOURCE.GAEVENTCATEGORY, SOURCE.Datum, SOURCE.Device, SOURCE.eventcount, SOURCE.Uniqueevents, SOURCE. eventvalue, SOURCE.labelz, SOURCE.urlz, SOURCE."HITSTAMP", SOURCE.EVENT_INFO, SOURCE."SESSIONID", SOURCE.vehicleid, SOURCE."RANK", SOURCE."GOAL_EVENT"
)