How to pass input parameter to AWS Glue Map.apply function

1.6k Views Asked by At

I am working on an AWS Glue job where I have a function "some_function" that I want to apply on DynamicFrame dy_f, but I also want to pass an input param to some_function.

Map.apply(frame=products_combination, f=search)

where some_function's definition is:

some_function(record, k)

What I've tried so far: Works:

Map.apply(frame=products_combination, f=search) ##provided i'm not taking k as input in some_function def as well

What is giving error:

Map.apply(frame=products_combination, f=search(k=10))

This returns "TypeError: search() missing 1 required positional argument: 'record'"

How can I pass a parameter to Map.apply function? I have gone through the documentation [here] but couldn't find my solution there.1

2

There are 2 best solutions below

1
On BEST ANSWER

I eventually used Spark udf instead of DynamicFrame.Map.apply. Worked for me.

0
On

You can always pass in additional parameters with lambda:

Map.apply(frame=products_combination, f=lambda record: search(record, k=10))