Amazon Redshift 支援用 Python 寫 UDF

Amazon Redshift 剛剛公佈可以使用 Python 寫 UDF:「Introduction to Python UDFs in Amazon Redshift」。

Redshift 是先編成 byte code 後再跑,所以不會有 C 或是 C++ 那麼快:

The Python execution in Amazon Redshift is also run as compiled byte code. Although this still won’t be as fast as the native C++ that runs your SQL, it will still be much faster than running through a Python interpreter.

不過因為彈性增加,以前必須用多個 SQL 甚至透過 temporily table 多次運算才能組出來的計算,現在用 UDF 應該會快很多。

Periscope 的人則馬上放出來一份他門所撰寫的版本:「Redshift User Defined Functions in Python」,程式可以在 GitHub 上的「Redshift UDF Harness」這邊取得。

可以用 UDF 變得方便很多啊,權重計算之類的好做不少...

Leave a Reply

Your email address will not be published. Required fields are marked *