Getting extra / charactor after importing data to dynamodb from s3

Viewed 27

I'm getting extra \ character after importing data to a new dynamodb from an S3 backup. Im am using was glue ETL job for this and it's working fine. But after importing I'm getting this issue.

I need to import it without \ character to the dynamoDB AWS Glue ETL script

import sys
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.job import Job
args = getResolvedOptions(sys.argv, ["JOB_NAME"])
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
job = Job(glueContext)
job.init(args["JOB_NAME"], args)
Source = glueContext.create_dynamic_frame.from_catalog(database = "Dev-UserProgram", table_name = "data", transformation_ctx = "Source")
# Script generated for node S3 bucket
S3bucket_node1 = glueContext.create_dynamic_frame.from_catalog(
    database="dev-userprogram",
    table_name="data",
    transformation_ctx="S3bucket_node1",
)
Mapped = ApplyMapping.apply(frame = Source, mappings = [
    ("Item.UserProgramId", "string", "UserProgramId", "string"),
    ("Item.UserProgram", "string", "UserProgram", "string")],
    transformation_ctx = "Mapped")
glueContext.write_dynamic_frame_from_options (
    frame = Mapped, 
    connection_type = "dynamodb", 
    connection_options = { "dynamodb.region": "ap-southeast-2", 
    "dynamodb.output.tableName": "Dev-UserProgram", 
    "dynamodb.throughput.write.percent": "1.0" } 
    )
job.commit()

output :

{
  "UserProgramId": {
    "S": "{\"S\": \"d135a9a8163d486d9398622e4301ab1b\"}"
  },
  "UserProgram": {
    "S": "{\"M\": {\"EmailAddress\": {\"S\": \"test@gmail.com\"}, \"EndDateUTC\": {\"S\": \"2021-02-12T11:12:55.543Z\"}, \"FixedDuration\": {\"BOOL\": true}, \"HasCompleted\": {\"BOOL\": false}, \"PlanType\": {\"N\": \"1\"}, \"RowVersion\": {\"S\": \"637516535873894162\"}, \"ScheduleId\": {\"S\": \"4f4fe32cd8424cc190bbcfa3cdc8f2c1\"}, \"StartDateRangeKey\": {\"S\": \"2021-03-18T08:39:47\"}, \"StartDateUTC\": {\"S\": \"2021-03-18T08:39:47.3851194Z\"}, \"UserProgramId\": {\"S\": \"d135a9a8163d486d9398622e4301ab1b\"}, \"UserProgress\": {\"L\": []}, \"__typename\": {\"S\": \"UserProgram\"}}}"
  }
}
0 Answers
Related