[ 
https://issues.apache.org/jira/browse/AVRO-1702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16431025#comment-16431025
 ] 

ASF GitHub Bot commented on AVRO-1702:
--------------------------------------

aprgoog commented on a change in pull request #302: AVRO-1702: Added support 
for logical types in the C++ client.
URL: https://github.com/apache/avro/pull/302#discussion_r180186426
 
 

 ##########
 File path: lang/c++/impl/Compiler.cc
 ##########
 @@ -327,6 +338,50 @@ static NodePtr makeRecordNode(const Entity& e,
         fieldValues, fieldNames, defaultValues));
 }
 
+static LogicalType makeLogicalType(const Entity& e, const Object& m) {
+    if (!containsField(e, m, "logicalType")) {
+        return LogicalType(LogicalType::NONE);
+    }
+
+    const std::string& typeField = getStringField(e, m, "logicalType");
+
+    if (typeField == "decimal") {
+        LogicalType decimalType(LogicalType::DECIMAL);
+        try {
+            decimalType.setPrecision(getLongField(e, m, "precision"));
+            if (containsField(e, m, "scale")) {
+                decimalType.setScale(getLongField(e, m, "scale"));
+            }
+        } catch (Exception& ex) {
+            // If any part of the logical type is malformed, per the standard 
we
+            // must ignore the whole attribute.
+            return LogicalType(LogicalType::NONE);
+        }
+        return decimalType;
+    }
+    if (typeField == "date") {
 
 Review comment:
   Done.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Add LogicalType support to c++ library
> --------------------------------------
>
>                 Key: AVRO-1702
>                 URL: https://issues.apache.org/jira/browse/AVRO-1702
>             Project: Avro
>          Issue Type: New Feature
>          Components: c++
>            Reporter: peter liu
>            Assignee: peter liu
>            Priority: Major
>
> I'd like to port the logicaltype support to c++ library



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to