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
preguntada hace 2 años635 visualizaciones
2 Respuestas
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
respondido hace 2 años
AWS
EXPERTO
revisado hace 2 años
0
Respuesta aceptada

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
EXPERTO
respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas