[
https://issues.apache.org/jira/browse/AVRO-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16757129#comment-16757129
]
Rumeshkrishnan commented on AVRO-2299:
--------------------------------------
I was thinking this way, creating new class SchemaCanonicalizer with
following method.
{code:java}
public class SchemaCanonicalizer {
private SchemaCanonicalizer() {}
private static final Set<String> RESERVED_PROPERTIES = new LinkedHashSet<>();
static {
Collections.addAll(RESERVED_PROPERTIES,
"name", "type", "fields", "symbols", "items", "values",
"logicalType", "size", "doc", "aliases", "default" );
}
public static String toCanonicalForm(Schema s) {
return build(s, RESERVED_PROPERTIES).toString();
}
public static String toCanonicalForm(Schema s, Set<String> properties) {
Set<String> props = new LinkedHashSet<>();
props.addAll(RESERVED_PROPERTIES);
props.addAll(properties);
return build(s, props).toString();
}
private static Appendable build(Schema s, Set<String> properties) = ???
}
{code}
Let me know, your thought [~cutting]. I feel that, we should not allow user to
get schema without Avro reserved fields.
> Get Plain Schema
> ----------------
>
> Key: AVRO-2299
> URL: https://issues.apache.org/jira/browse/AVRO-2299
> Project: Apache Avro
> Issue Type: New Feature
> Components: java
> Affects Versions: 1.8.2
> Reporter: Rumeshkrishnan
> Priority: Minor
> Labels: features
> Fix For: 1.9.0, 1.8.2, 1.8.3, 1.8.4
>
>
> {panel:title=Avro Schema Reserved Keys:}
> "doc", "fields", "items", "name", "namespace",
> "size", "symbols", "values", "type", "aliases", "default"
> {panel}
> AVRO also supports user defined properties for both Schema and Field.
> Is there way to get the schema with reserved property (key, value)?
> Input Schema:
> {code:java}
> {
> "name": "testSchema",
> "namespace": "com.avro",
> "type": "record",
> "fields": [
> {
> "name": "email",
> "type": "string",
> "doc": "email id",
> "user_field_prop": "xxxxx"
> }
> ],
> "user_schema_prop": "xxxxxx"
> }{code}
> Expected Plain Schema:
> {code:java}
> {
> "name": "testSchema",
> "namespace": "com.avro",
> "type": "record",
> "fields": [
> {
> "name": "email",
> "type": "string",
> "doc": "email id"
> }
> ]
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)