I am using AWS Glue and need to transform Boolean (True and False), columns within a Redshift datawarehouse schema to a "Yes"/"No" in another Redshift schema. At present, there does not appear to be a simple way to do so in the AWS Glue GUI.
I have been following the guide here as: https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-transforms-map.html
and created the function:
def ConvertBoolean(dataFrame,ColumnName):
dataFrame["booleanTransform"] = {}
if dataFrame[ColumnName] == True:
dataFrame["booleanTransform"] = "Yes"
else:
dataFrame["booleanTransform"] = "No"
del dataFrame[ColumnName]
dataFrame[ColumnName] = {}
dataFrame[ColumnName] = dataFrame["booleanTransform"]
del dataFrame["booleanTransform"]
return dataFrame
But do not know where the function should be stored or how to pass the dynamicframe as that is not noted in the documentation example provided.
How would this be best accomplished in the pyspark code of AWS Glue?