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

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

thiru-apache commented on a change in pull request #345:  AVRO-1256: C++ API 
compileJsonSchema ignores "doc" and custom attributes on a field/record
URL: https://github.com/apache/avro/pull/345#discussion_r224993111
 
 

 ##########
 File path: lang/c++/impl/Compiler.cc
 ##########
 @@ -314,16 +335,20 @@ static Field makeField(const Entity& e, SymbolTable& st, 
const string& ns)
     Object::const_iterator it = findField(e, m, "type");
     map<string, Entity>::const_iterator it2 = m.find("default");
     NodePtr node = makeNode(it->second, st, ns);
+    if (containsField(m, "doc")) {
+        node->setDoc(getDocField(e, m));
+    }
     GenericDatum d = (it2 == m.end()) ? GenericDatum() :
         makeGenericDatum(node, it2->second, st);
     return Field(n, node, d);
 }
 
-static NodePtr makeRecordNode(const Entity& e,
-    const Name& name, const Object& m, SymbolTable& st, const string& ns)
-{
+// Extended makeRecordNode (with doc).
+static NodePtr makeRecordNode(const Entity& e, const Name& name,
+                              const std::string* doc, const Object& m,
+                              SymbolTable& st, const std::string& ns) {
     const Array& v = getArrayField(e, m, "fields");
-    concepts::MultiAttribute<string> fieldNames;
+    concepts::MultiAttribute<std::string> fieldNames;
 
 Review comment:
   Inside `cc` files we try to avoid using `std::` prefix and instead use plain 
`string` etc along with `using` directive. We never use `using` in header file. 
We follow the advice [59. Don’t write namespace usings in a header file or 
before an 
#include](https://www.safaribooksonline.com/library/view/c-coding-standards/0321113586/ch60.html)

----------------------------------------------------------------
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:
[email protected]


> C++ API compileJsonSchema ignores "doc" and custom attributes on a 
> field/record
> -------------------------------------------------------------------------------
>
>                 Key: AVRO-1256
>                 URL: https://issues.apache.org/jira/browse/AVRO-1256
>             Project: Avro
>          Issue Type: Improvement
>          Components: c++
>    Affects Versions: 1.7.2
>         Environment: Running on all platforms (Windows, OSX, Linux)
>            Reporter: Tim Menninger
>            Priority: Minor
>         Attachments: AVRO-1256.patch
>
>
> It appears that when my JSON is compiled into a valid schema object it is 
> ignoring all types of "documentation" that I am trying to adorn with each 
> field in my record. Reading through the Java issues it seems that this was a 
> bug and fixed (AVRO-601, AVRO-612, AVRO-779) but it seems the C++ 
> implementation has yet to adopt this feature? This is my sample schema, I 
> have attempted to insert both "doc" and "mycustom" in multiple places to see 
> if it is supported at any level. Please excuse if there appears to be a 
> syntax error in the JSON I hand tweaked some of this. The schema is valid and 
> successfully parses.
> {
>       "type": "record",
>       "name": "myschema",
>       "doc": "Doc Meta",
>       "mycustom": "My Custom",
>       "fields": [
>               { "name":"field_a","type":["string","null"], "doc":"Doc Meta", 
> "mycustom":"My Custom A"},
>               { "name":"field_b","type":["string","null"], "doc":"Doc Meta", 
> "mycustom":"My Custom B"},
>               { "name":"field_c","type":["string","null"], "doc":"Doc Meta", 
> "mycustom":"My Custom C"}
>       ]
> }
> I looked through the SchemaTests.cc code for 1.7.3 and there was not a test 
> case for this there so i didn't think this was addressed in that version. I 
> am running 1.7.2. When this schema is used to load with compileJsonSchema and 
> then a file is serialized the file schema looks like this.
> {
>       "type":"record",
>       "name":"myschema",
>       "fields": [
>               { "name":"field_a","type":["string","null"]},
>               { "name":"field_b","type":["string","null"]},
>               { "name":"field_c","type":["string","null"]}
>       ]
> }



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

Reply via email to