0

I used AWS Glue Transform-custom code, and wrote the following code.

def MyTransform (glueContext, dfc) -> DynamicFrameCollection:

    from pyspark.sql.functions import col, lit
    selected = dfc.select(list(dfc.keys())[0]).toDF()
    selected = selected.withColumn('item2',lit(col('item1')))
    results = DynamicFrame.fromDF(selected, glueContext, "results")
    return DynamicFrameCollection({"results": results}, glueContext)

I got the following error.

AnalysisException: cannot resolve '`item1`' given input columns: [];

1 Answer 1

1

You don't need to wrap lit(col('item1')). lit is used to create a literal static value, while col is to refer to a specific column. Depends on what exactly you're trying to achieve, but this change will at least fix your error

selected = selected.withColumn('item2', col('item1'))
Sign up to request clarification or add additional context in comments.

1 Comment

great, feel free to accept the answer and close the thread

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.