odps spark節點不僅可以使用java代碼進行資料處理,也可以使用python進行資料處理。
注意:由于python資源是針對Python udf
進行開發,其所能擷取到的直接依賴的三方包非常有限,故而python資源使用局限性比較大,很多三方包在python資源裡都沒有支援,自定義添加步驟、操作繁複。
python資源引用三方依賴可仿照此文檔:
https://yq.aliyun.com/articles/591478而在pyodps2/pyodps3節點内支援性比較豐滿,支援性更好。
以下是python樣例:

1.簡單demo示例(非資料業務處理邏輯,簡單案例進行校驗數值判斷)
建立python檔案:
樣例demo(僅做參考使用):
def is_number(s):
try:
float(s)
return True
except ValueError:
pass
import unicodedata
unicodedata.numeric(s)
except (TypeError, ValueError):
return False
print(is_number('foo'))
print(is_number('1'))
print(is_number('1.3'))
print(is_number('-1.37'))
print(is_number('1e3'))
python檔案儲存送出釋出即為odps/dataworkspy資源檔案,這時候已經可以使用spark節點引用了。
2.建立odps spark節點并加載剛剛送出的python資源:
釋出後即可執行測試
DataWorks百問百答曆史記錄
請點選這裡檢視>>更多DataWorks技術和産品資訊,歡迎加入
【DataWorks釘釘交流群】