Add ability to disable Decimal usage for DynamoDB number type.
See original GitHub issueHi,
Is there any strong reason why using a DynamoDB’s Table resource will convert the number type "N"
to a Decimal()
object?
Shouldn’t it try looking up the right python type, such as int
or float
or long
?
I am trying to unpack a record’s data (a mapping) into a function call, specifically: next_execution = now() + datetime.timedelta(**dynamo_record['frequency'])
but datetime.timedelta will not accept the Decimal object into its arguments, although it does accept long
and float
.
TypeError: unsupported type for timedelta days component: Decimal
Issue Analytics
- State:
- Created 8 years ago
- Reactions:90
- Comments:108 (5 by maintainers)
Top Results From Across the Web
Supported data types for DynamoDB Mapper for Java
Learn about the data types supported when using DynamoDB Mapper and the AWS SDK for ... Set collection types, SS (string set) type,...
Read more >Amazon DynamoDB: Storing integers as Numbers vs. Strings
I know that DynamoDB already stores Numbers as strings at some point in the background, but I'm unsure if there is possibility for...
Read more >Source code for boto3.dynamodb.types - AWS
You # may not use this file except in compliance with the License. ... that ``Decimal`` objects are used to be able to...
Read more >Amazon Redshift Numeric: 3 Data Types Simplified
In AWS, Integer, Decimal, and Floating-point are all referred to by the term Redshift Numeric Data Types.
Read more >Decimal type | CDP Public Cloud
The decimal type is a numeric data type with fixed scale and precision suitable for financial and other arithmetic calculations where the imprecise ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW, I use this little function to recurse into Python objects returned by the boto3 DynamoDB resource layer and convert any Decimal values to
int
orfloat
. It is by no means foolproof and doesn’t in any way solve the problem of lack of precision in Python’s float type but it solves my problem which is mainly to turn the data into something that can be returned to API Gateway via a Python Lambda function.Would adding some sort of
use_decimal=False
option to the config object when creating clients/resources be helpful?