MaxCompute Studio的Project Explorer提供了可視化編輯器,可以協助您快速在MaxCompute專案中註冊自訂函數(MaxCompute UDF),並提供查看MaxCompute UDF實現代碼、刪除MaxCompute UDF的操作入口。本文為您介紹如何通過Project Explorer可視化註冊、查看或刪除MaxCompute UDF。
背景資訊
MaxCompute Studio支援的函數及相應操作如下。
函數操作 | 說明 | ||
|
| 無。 | |
|
|
| |
修改函數 |
|
|
|
|
| 無。 |
註冊函數
註冊函數前,請確認函數依賴的資源已上傳至MaxCompute專案中,更多上傳資源操作,請參見添加資源。
在IntelliJ IDEA介面的頂部功能表列,選擇。
在Create Function對話方塊配置下表所列參數資訊。
參數
說明
MaxCompute project
待註冊函數的MaxCompute專案名稱。
如果MaxCompute Studio已與目標MaxCompute專案建立串連,您可以直接從下拉式清單選擇目標MaxCompute專案。如果下拉式清單未找到目標MaxCompute專案,您可以單擊右側
表徵圖添加MaxCompute專案。Function name
新註冊函數的名稱,即後續在SQL中調用的函數名稱。函數名稱全域唯一。
您可以在IntelliJ IDEA介面的左側導覽列,單擊Project Explorer,按右鍵目標MaxCompute專案下的Functions,查看已存在的函數名稱。
Using resources
待註冊函數依賴的資源檔。您可以在資源清單中單擊選中目標資源檔。如果函數依賴多個資源檔,按住Ctrl鍵逐個單擊需要的資源檔即可選中多個。
Main class
新註冊函數的類名。即函數依賴的資源檔JAR包或PY指令碼中定義的類。
Force update if already exists
選中該項,表示當MaxCompute專案中存在同名函數時,新函數會替代舊函數。
在Create Function對話方塊,單擊OK,完成函數註冊。
在Project Explorer地區,按右鍵目標MaxCompute專案下的Functions,選擇Refresh meta更新資訊後,在列表中可以查看到新註冊的函數。
查看函數
內建函數
在IntelliJ IDEA介面的左側導覽列,單擊Project Explorer,在目標MaxCompute專案的Functions下,雙擊Builtln下的內建函數名稱,即可查看函數的文法格式資訊。
MaxCompute UDF
在IntelliJ IDEA介面的左側導覽列,單擊Project Explorer,在目標MaxCompute專案的Functions下,雙擊UserDefined下的函數名稱或在函數名稱上單擊右鍵選擇Show function detail,即可開啟函數實現代碼介面。單擊UserDefined下的函數名稱即可查看函數的文法格式資訊。
// // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) // package com.aliyun.odps.udf.example; import com.aliyun.odps.udf.UDF; public final class Lower extends UDF { public Lower() { } public String evaluate(String s) { return s == null ? null : s.toLowerCase(); } }
刪除函數
在IntelliJ IDEA介面的左側導覽列,單擊Project Explorer,在目標MaxCompute專案的Functions下,按右鍵需要刪除的函數,選擇Delete function from server。
在Confirmation Required對話方塊,單擊OK,即可從MaxCompute專案中刪除函數。
按右鍵目標MaxCompute專案下的Functions,選擇Refresh meta更新資訊後,列表中將無法查看到刪除的函數。