[
https://issues.apache.org/jira/browse/AVRO-3547?focusedWorklogId=792873&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-792873
]
ASF GitHub Bot logged work on AVRO-3547:
----------------------------------------
Author: ASF GitHub Bot
Created on: 19/Jul/22 18:21
Start Date: 19/Jul/22 18:21
Worklog Time Spent: 10m
Work Description: emkornfield commented on code in PR #1736:
URL: https://github.com/apache/avro/pull/1736#discussion_r924828452
##########
lang/c++/impl/Compiler.cc:
##########
@@ -256,6 +260,26 @@ static GenericDatum makeGenericDatum(NodePtr n,
}
}
+static const std::unordered_set<std::string>& getKnownFields() {
+ // return known fields
+ static const std::unordered_set<std::string> kKnownFields =
+ {"name", "type", "default", "doc", "size", "logicalType",
+ "values", "precision", "scale", "namespace"};
+ return kKnownFields;
+}
+
+static void getCustomAttributes(const Object& m, CustomFields
&customAttributes)
+{
+ // Don't add known fields on primitive type and fixed type into custom
+ // fields.
+ const std::unordered_set<std::string>& kKnownFields = getKnownFields();
+ for (const auto &entry : m) {
+ if (kKnownFields.find(entry.first) == kKnownFields.end()) {
Review Comment:
actually this is C++20 so probably not portable.
Issue Time Tracking
-------------------
Worklog Id: (was: 792873)
Time Spent: 3h (was: 2h 50m)
> support custom attribute at field level
> ---------------------------------------
>
> Key: AVRO-3547
> URL: https://issues.apache.org/jira/browse/AVRO-3547
> Project: Apache Avro
> Issue Type: Improvement
> Components: c++
> Reporter: Nilesh Yadav
> Priority: Major
> Labels: pull-request-available
> Time Spent: 3h
> Remaining Estimate: 0h
>
> Custom attributes are allowed at field level as per Avro specification :
> [https://avro.apache.org/docs/current/spec.html#schemas|https://www.google.com/url?q=https://avro.apache.org/docs/current/spec.html%23schemas&sa=D&source=buganizer&usg=AOvVaw3JfXMgFX6Eq0Fd0TjDzgb1]
>
> But Avro c++ implementation does not support custom attribute at field level.
> e.g. following schema cannot be parsed correctly due to presence of "sqlName"
> attribute.
> {
> 'doc': 'weather warning',
> 'name': 'weather',
> 'type': 'record',
> 'fields': [
> {
> 'name': 'station',
> 'type':'string',
> 'sqlName':'abc-@12'
> },
> {
> 'name': 'time',
> 'type':'long',
> 'sqlName': '用户名'
> }]
> }
> Update implementation to support custom attribute at field level.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)