Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
367 views
in Technique[技术] by (71.8m points)

How to represent a sort key of type number in a Glue python job script

I want to use AWS Glue to import that data into a dynamoDB table with partion key 'classId' (string) and sort key 'itemId' (number)

Can someone tell me how to represent the sort key in the Glue job script I am using

When I do

# Map the source field names and data types to target values. The target values should be exactly the 
# same as the source DyanmoDB table values
Mapped = ApplyMapping.apply(frame = Source, mappings = [
                        ("item.classId.S", "string", "classId", "string"), 
                        ("item.itemId.N", "number", "itemId", "number"),
                       ],
                        transformation_ctx = "Mapped")

I get the error IllegalArgumentException: 'Invalid type name number'

If I use ("item.itemId.N", "string", "itemId", "string"),

I get the error The provided key element does not match the schema

How do I represent the sort key in this code ?

Thanks for any help

question from:https://stackoverflow.com/questions/65945169/how-to-represent-a-sort-key-of-type-number-in-a-glue-python-job-script

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The AWS Glue using Dynamic DataFrame (LINK) by default when you load your data. You could find the list of available data types for the dynamic DataFrame HERE.
When you use mapping you are going to rename and convert data types at the same time (source column, source type, target column, target type). So the column types in both source and destination are important.
I reckon if you chgnage your line to ("item.itemId.N", "double", "itemId", "double") it will work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...