Glue Studio Designer: use pyspark functions

0

I designed a glue job using Glue studio designer canvas feature and am using a custom transform in there. However, I am struggling to leverage functions like the ones from 'from pyspark.sql.functions import *' in the code as I get error "NameError: name xyz not defined.
How can I leverage these functions in the canvas tool?

  • so is it a best practice to run the imports within the function fo the custom transform?

AWS
Marco
已提問 2 年前檢視次數 635 次
2 個答案
1

Try importing specific function instead of import *. For example, "from pyspark.sql.functions import split" to import split function.

I tried replicating your problem, it complained that import * can only be used at module level. But when I changed to specific function, it worked.

Hope this help.

AWS-TDN
已回答 2 年前
AWS
專家
已審閱 2 年前
0
已接受的答案

Hi ,

yes, any library you need for your custom transform should be imported within the function.

just to consider if you want to run SparkSQL you could also use the SQL transform.

hope this helps,

AWS
專家
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南