在AWS Glue中更改动态框架的列数据类型需要进行以下步骤:
# create a dynamic frame
dynamic_frame = glueContext.create_dynamic_frame.from_catalog(database='mydb', table_name='mytable')
# select specific column
df = dynamic_frame.select_fields(['col1'])
# resolve choice as per the data type you need
data_frame = df.toDF().withColumn('col1', df['col1'].cast('integer'))
# convert back to dynamic frame
dyf = DynamicFrame.fromDF(data_frame, glueContext, 'dyf')
glueContext.write_dynamic_frame.from_jdbc_conf(
frame = dyf,
catalog_connection = "myRedshiftConnection",
connection_options = {"dbtable": "mytable", "database": "mydb"},
redshift_tmp_dir = args["TempDir"],
transformation_ctx = "datasink")