Hologres開發(fā):周期性調(diào)度
HoloStudio與DataWorks無縫連通,您可以通過HoloStudio將MaxCompute數(shù)據(jù)導(dǎo)入Hologres,并基于DataWorks的底層能力,前往DataWorks進(jìn)行定時(shí)調(diào)度,實(shí)現(xiàn)周期性導(dǎo)入數(shù)據(jù)至Hologres。本文為您介紹如何將MaxCompute源表數(shù)據(jù)導(dǎo)入Hologres進(jìn)行周期性調(diào)度。
HoloStudio已下線,詳情請參見DataWorks HoloStudio下線公告。
操作步驟
準(zhǔn)備MaxCompute表數(shù)據(jù)。
準(zhǔn)備一張MaxCompute數(shù)據(jù)源表,您可以參考MaxCompute創(chuàng)建表進(jìn)行建表,也可以直接從數(shù)據(jù)地圖中選用一張表。示例選用數(shù)據(jù)地圖中已創(chuàng)建的表,其建表DDL語句如下。
CREATE TABLE IF NOT EXISTS bank_data_odps ( age BIGINT COMMENT '年齡', job STRING COMMENT '工作類型', marital STRING COMMENT '婚否', education STRING COMMENT '教育程度', card STRING COMMENT '是否有信用卡', housing STRING COMMENT '房貸', loan STRING COMMENT '貸款', contact STRING COMMENT '聯(lián)系途徑', month STRING COMMENT '月份', day_of_week STRING COMMENT '星期幾', duration STRING COMMENT '持續(xù)時(shí)間', campaign BIGINT COMMENT '本次活動聯(lián)系的次數(shù)', pdays DOUBLE COMMENT '與上一次聯(lián)系的時(shí)間間隔', previous DOUBLE COMMENT '之前與客戶聯(lián)系的次數(shù)', poutcome STRING COMMENT '之前市場活動的結(jié)果', emp_var_rate DOUBLE COMMENT '就業(yè)變化速率', cons_price_idx DOUBLE COMMENT '消費(fèi)者物價(jià)指數(shù)', cons_conf_idx DOUBLE COMMENT '消費(fèi)者信心指數(shù)', euribor3m DOUBLE COMMENT '歐元存款利率', nr_employed DOUBLE COMMENT '職工人數(shù)', y BIGINT COMMENT '是否有定期存款' );
新建外部表。
進(jìn)入HoloStudio,在PG管理或SQL Console中新建一張外部表,用于映射MaxCompute源表數(shù)據(jù)。示例新建外部表的SQL語句如下。
begin; CREATE FOREIGN TABLE "public"."bank_data_foreign_holo" ( "age" int8, "job" text, "marital" text, "education" text, "card" text, "housing" text, "loan" text, "contact" text, "month" text, "day_of_week" text, "duration" text, "campaign" int8, "pdays" float8, "previous" float8, "poutcome" text, "emp_var_rate" float8, "cons_price_idx" float8, "cons_conf_idx" float8, "euribor3m" float8, "nr_employed" float8, "y" int8 ) SERVER odps_server OPTIONS (project_name 'odps_4_holoworkshop_dev', table_name 'bank_data_odps'); COMMIT;
OPTIONS的連接參數(shù)說明如下表所示。
參數(shù)
描述
project_name
MaxCompute的項(xiàng)目名稱。
table_name
MaxCompute的表名稱。
新建存儲表。
在HoloStudio中新建一張用于接收并存儲數(shù)據(jù)的真實(shí)存儲表。字段類型需要與外部表保持一致。示例DDL語句如下。
begin; create table if not exists bank_data_holo ( age int8, job text, marital text, education text, card text, housing text, loan text, contact text, month text, day_of_week text, duration text, campaign int8, pdays float8, previous float8, poutcome text, emp_var_rate float8, cons_price_idx float8, cons_conf_idx float8, euribor3m float8, nr_employed float8, y int8, ds text not null ) partition by list(ds); call set_table_property('bank_data_holo', 'orientation', 'column'); call set_table_property('bank_data_holo', 'time_to_live_in_seconds', '700000'); commit;
新建分區(qū)表的數(shù)據(jù)開發(fā)。
并單擊上方新建Hologres開發(fā),輸入作業(yè)邏輯,單擊保存--前往DataWorks調(diào)度,示例SQL如下:
在HoloStudio中,單擊左側(cè)導(dǎo)航欄的圖標(biāo),進(jìn)入數(shù)據(jù)開發(fā)頁面。
鼠標(biāo)懸停至圖標(biāo),單擊Hologres開發(fā)。
配置新建節(jié)點(diǎn)對話框的節(jié)點(diǎn)名稱、目標(biāo)文件夾及數(shù)據(jù)庫參數(shù)。
單擊提交,成功創(chuàng)建Hologres開發(fā)節(jié)點(diǎn)。
在新建的Hologres開發(fā)節(jié)點(diǎn)的編輯界面,輸入如下創(chuàng)建分區(qū)表的數(shù)據(jù)開發(fā)語句。
create table if not exists bank_data_holo_1_${bizdate} partition of bank_data_holo for values in ('${bizdate}'); insert into bank_data_holo_1_${bizdate} select age as age, job as job, marital as marital, education as education, card as card, housing as housing, loan as loan, contact as contact, month as month, day_of_week as day_of_week, duration as duration, campaign as campaign, pdays as pdays, previous as previous, poutcome as poutcome, emp_var_rate as emp_var_rate, cons_price_idx as cons_price_idx, cons_conf_idx as cons_conf_idx, euribor3m as euribor3m, nr_employed as nr_employed, y as y, '${bizdate}' as ds from bank_data_foreign_holo;
單擊頂部菜單欄左側(cè)的,保存Hologres開發(fā)。
單擊頂部菜單欄右側(cè)的前往DataWorks調(diào)度,進(jìn)入調(diào)度頁面。
新建分區(qū)表的調(diào)度作業(yè)。
在DataWorks中新建Hologres節(jié)點(diǎn)。
單擊前往DataWorks調(diào)度后,頁面自動跳轉(zhuǎn)至DataWorks的新建節(jié)點(diǎn)。您需要配置新建節(jié)點(diǎn)對話框的節(jié)點(diǎn)類型、節(jié)點(diǎn)名稱及目標(biāo)文件夾,創(chuàng)建Hologres節(jié)點(diǎn)。節(jié)點(diǎn)類型選擇Hologres開發(fā)。
如果是重新執(zhí)行已有作業(yè),則可以不需要重新創(chuàng)建節(jié)點(diǎn)。
在新建的節(jié)點(diǎn)頁面,單擊更新節(jié)點(diǎn)版本,將分區(qū)表的信息同步至該節(jié)點(diǎn)。
配置調(diào)度信息。
在新建的節(jié)點(diǎn)頁面,單擊右側(cè)導(dǎo)航欄的調(diào)度配置,配置調(diào)度參數(shù)。詳情請參見調(diào)度參數(shù)支持的格式。
具體配置如下所示:
配置基礎(chǔ)屬性。
在基礎(chǔ)屬性區(qū)域,將參數(shù)賦值為時(shí)間節(jié)點(diǎn)。
配置時(shí)間屬性。
在時(shí)間屬性區(qū)域,配置時(shí)間屬性為正常調(diào)度。其余參數(shù)請根據(jù)業(yè)務(wù)實(shí)際情況配置,詳情請參見時(shí)間屬性配置說明。
配置調(diào)度依賴。
在調(diào)度依賴區(qū)域,您需要配置調(diào)度依賴為root節(jié)點(diǎn),操作如下:
將自動解析配置為是。
單擊使用工作空間根節(jié)點(diǎn),自動解析出root節(jié)點(diǎn)。
再將自動解析配置為否,詳情請參見配置同周期調(diào)度依賴。
您也可以根據(jù)業(yè)務(wù)邏輯選擇已有的父節(jié)點(diǎn)。
發(fā)布調(diào)度。
配置完調(diào)度參數(shù),在新建節(jié)點(diǎn)頁面的頂部菜單欄左側(cè),單擊圖標(biāo),保存調(diào)度配置。
在新建節(jié)點(diǎn)頁面的頂部菜單欄左側(cè),單擊圖標(biāo),提交調(diào)度信息。
在新建節(jié)點(diǎn)頁面的頂部菜單欄右側(cè),單擊發(fā)布,前往任務(wù)發(fā)布頁面。
在任務(wù)發(fā)布頁面,選中當(dāng)前任務(wù),單擊目標(biāo)任務(wù)操作列的發(fā)布。發(fā)布包提交成功后,單擊上方菜單欄運(yùn)維中心進(jìn)行手工補(bǔ)數(shù)據(jù)。
在確認(rèn)發(fā)布對話框,單擊發(fā)布。
發(fā)布包提交成功后,單擊任務(wù)發(fā)布頁面頂部菜單欄右側(cè)的運(yùn)維中心,進(jìn)入運(yùn)維中心。
在左側(cè)導(dǎo)航欄,單擊 ,勾選并單擊目標(biāo)任務(wù)名稱。
在右側(cè)編輯界面,鼠標(biāo)右鍵單擊目標(biāo)任務(wù)節(jié)點(diǎn),選擇 。
根據(jù)業(yè)務(wù)實(shí)際情況,配置補(bǔ)數(shù)據(jù)對話框的各項(xiàng)參數(shù)。完成調(diào)度任務(wù)的發(fā)布。
任務(wù)執(zhí)行成功后,返回HoloStudio。單擊新建節(jié)點(diǎn)的圖標(biāo),刷新當(dāng)前頁面。您可以在PG管理模塊找到目標(biāo)分區(qū)表,查看調(diào)度成功的分區(qū)表數(shù)據(jù)。
雙擊目標(biāo)表名稱,在表編輯頁面單擊數(shù)據(jù)預(yù)覽,即可看到已成功導(dǎo)入的數(shù)據(jù)。
您也可以使用SQL語句查看父表或分區(qū)表的數(shù)據(jù),示例如下。
SELECT * FROM bank_data_holo;