3

how can I show the DataFrame with job etl of aws glue?

I tried this code below but doesn't display anything.

df.show()

code

datasource0 = glueContext.create_dynamic_frame.from_catalog(database = "flux-test", table_name = "tab1", transformation_ctx = "datasource0")
sourcedf = ApplyMapping.apply(frame = datasource0, mappings = [("id", "long", "id", "long"),("Rd.Id_Releve", "string", "Rd.Id_R", "string")])
 sourcedf = sourcedf.toDF()
 data = []
 schema = StructType(
[
    StructField('PM',
        StructType([
            StructField('Pf', StringType(),True),
            StructField('Rd', StringType(),True)
    ])
    ),
    ])
 cibledf = sqlCtx.createDataFrame(data, schema)
 cibledf = sqlCtx.createDataFrame(sourcedf.rdd.map(lambda x:    Row(PM=Row(Pf=str(x.id_prm), Rd=None ))), schema)
 print(cibledf.show())
 job.commit()
ceo
  • 31
  • 1
  • 2
  • 7

1 Answers1

4

In your glue console, after you run your glue job, in job listing there would be a column for Logs / Error logs.

Click on the Logs and this would take you to the cloudwatch logs associated to your job. Browse though for the print statement.

also please check here: Convert dynamic frame to a dataframe and do show()

ADDed working/test code sample

Code sample:

zipcode_dynamicframe = glueContext.create_dynamic_frame.from_catalog(
       database = "customer_db",
       table_name = "zipcode_master")
zipcode_dynamicframe.printSchema()
zipcode_dynamicframe.toDF().show(10)

Screenshot for zipcode_dynamicframe.show() in cloudwatch log:

enter image description here

Yuva
  • 2,831
  • 7
  • 36
  • 60
  • I did exactly what you said . didn't find data frame in the log. Thank you – ceo Dec 27 '19 at 10:01
  • added code snippet and a screenshot from the cloud watch log...the logs by default would be collapsed, and you have expand and look out for ur df.show(). – Yuva Dec 27 '19 at 11:24