0

I have a code that converts DataFrame to DynamicFrame and I get this weird error when trying to execute return statement, any clues what's going on?

Error: {AttributeError}'str' object has no attribute '_jvm'

# record is DynamicFrame
def extractCustomFields(record, ctx):
    rec = record.toDF()
    rec = rec.withColumn("lastname", rec["customfields"][0].value)
    rec.show()
return DynamicFrame.fromDF(rec, ctx, "recordTransform")
1
  • fromDF(dataframe, glue_ctx, name) takes GlueContext as second param and you are passing str. Is your GlueContext initialized properly? Please see: fromDf Commented Nov 25, 2021 at 11:58

1 Answer 1

1

fromDF() expects the GlueContext as second argument. You need to pass that:

return DynamicFrame.fromDF(rec, ctx, "recordTransform")
Sign up to request clarification or add additional context in comments.

1 Comment

yes I was passing transformationContext instead of GlueContext

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.