[
https://issues.apache.org/jira/browse/AVRO-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16760256#comment-16760256
]
Rumeshkrishnan edited comment on AVRO-2299 at 2/4/19 9:51 PM:
--------------------------------------------------------------
As you mentioned canonical form for primitive types :-
*Input :*
{code:java}
{"type":"<primitive_types>", "x":"y"}
{code}
*Output:*
{code:java}
"<primitive_types>" //boolean, bytes, double, float, int, long, null, string
{code}
*Canonical form for Union:*
{code:java}
[ <avro Types>, ... ]{code}
*Canonical form for Record:*
{code:java}
{
"name": "---",
"namespace": "---", // optional if input contain then present
"type": "record",
"fields": [
{
"name": "---",
"types": ...,
"order": "---", // optional if input contain then present
"doc": "---", // optional if input contain then present
"aliases": ["---", ...], // optional if input contain then present
"default": ... // optional if input contain then present
}
...
]
}{code}
*Canonical form for Enum:*
{code:java}
{
"name": "---",
"namespace": "---", // optional if input contain then present
"type": "enum",
"symbols": [ ... ],
"doc": "---", // optional if input contain then present
"aliases": ["---", ...] // optional if input contain then present
}
{code}
*Canonical form for Fixed:*
{code:java}
{
"name": "---",
"namespace": "---", // optional if input contain then present
"type": "fixed",
"size": ...,
"aliases": ["---", ...] // optional if input contain then present
}
{code}
*Canonical form for Logical Types:*
{code:java}
{
"type": "...", // <primitive types>
"logicalType": "...." // reserved avro logical types or user registered
logical types
"precision": ..., // if logical type is decimal
"scale": ... // if logical type is decimal then optional if input contain
then present
}{code}
This is the order and rules, I am thinking of canonical normaliser can do.
Kindly review this as well [~cutting]
was (Author: rumeshkrish):
As you mentioned canonical form for primitive types :-
*Input :*
{code:java}
{"type":"<primitive_types>", "x":"y"}
{code}
*Output:*
{code:java}
"<primitive_types>" //boolean, bytes, double, float, int, long, null, string
{code}
*Canonical form for Record:*
{code:java}
{
"name": "---",
"namespace": "---", // optional if input contain then present
"type": "record",
"fields": [
{
"name": "---",
"types": ...,
"order": "---", // optional if input contain then present
"doc": "---", // optional if input contain then present
"aliases": ["---", ...], // optional if input contain then present
"default": ... // optional if input contain then present
}
...
]
}{code}
*Canonical form for Enum:*
{code:java}
{
"name": "---",
"namespace": "---", // optional if input contain then present
"type": "enum",
"symbols": [ ... ],
"doc": "---", // optional if input contain then present
"aliases": ["---", ...] // optional if input contain then present
}
{code}
*Canonical form for Fixed:*
{code:java}
{
"name": "---",
"namespace": "---", // optional if input contain then present
"type": "fixed",
"size": ...,
"aliases": ["---", ...] // optional if input contain then present
}
{code}
*Canonical form for Logical Types:*
{code:java}
{
"type": "...", // <primitive types>
"logicalType": "...." // reserved avro logical types or user registered
logical types
"precision": ..., // if logical type is decimal
"scale": ... // if logical type is decimal then optional if input contain
then present
}{code}
This is the order and rules, I am thinking of canonical normaliser can do.
Kindly review this as well [~cutting]
> 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)