You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/12/06 18:53:49 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #28158: Fix Type Error while using dynamodb_to_s3 operator

uranusjr commented on code in PR #28158:
URL: https://github.com/apache/airflow/pull/28158#discussion_r1041340212


##########
airflow/providers/amazon/aws/transfers/dynamodb_to_s3.py:
##########
@@ -36,8 +37,18 @@
     from airflow.utils.context import Context
 
 
+class JSONEncoder(json.JSONEncoder):
+    """Custom json encoder implementation"""
+
+    def default(self, obj):
+        """Convert decimal objects in a json serializable format."""
+        if isinstance(obj, Decimal):
+            return float(obj)
+        return json.JSONEncoder.default(self, obj)

Review Comment:
   ```suggestion
           return super().default(self, obj)
   ```



##########
airflow/providers/amazon/aws/transfers/dynamodb_to_s3.py:
##########
@@ -36,8 +37,18 @@
     from airflow.utils.context import Context
 
 
+class JSONEncoder(json.JSONEncoder):
+    """Custom json encoder implementation"""
+
+    def default(self, obj):
+        """Convert decimal objects in a json serializable format."""
+        if isinstance(obj, Decimal):
+            return float(obj)
+        return json.JSONEncoder.default(self, obj)

Review Comment:
   ```suggestion
           return super().default(obj)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org