avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom White (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1188) External Schema Imports via AVSC Schema
Date Mon, 12 Nov 2012 14:37:12 GMT

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

Tom White commented on AVRO-1188:
---------------------------------

Thanks for the patch, Sharmarke. I tried using the patch with a small project I was testing
AVRO-983 with and it worked fine. A few comments on the patch:

* Using a static Schema.Parser could potentially cause problems if the plugin is used more
than once in a Maven project, since only one parser instance is used and it would retain references
to earlier schemas. Instead, make it a non-static instance variable.
* If importing files then project.addCompileSourceRoot is called twice with the same output
directory. I'm not sure if this is a problem, but it might be better to call it just once.
* Nit: declaration of "File file" can be moved to the line where the object is first instantiated.
This occurs in two places in the patch.

                
> External Schema Imports via AVSC Schema
> ---------------------------------------
>
>                 Key: AVRO-1188
>                 URL: https://issues.apache.org/jira/browse/AVRO-1188
>             Project: Avro
>          Issue Type: New Feature
>          Components: java
>            Reporter: Sharmarke Aden
>         Attachments: Avro-1188.tar.gz, vcs-diff1160361655737792386.patch, vcs-diff2916139350460140957.patch,
vcs-diff4277815358664835838.patch
>
>
> There is no way for ".avsc" schema files to import types (i.e records, enums, etc) in
external schema files. There's tremendous benefit in being able to do this as it would allow
the sharing of common types between multiple schema files. Here's a use case that illustrates
the typical usecase of this feature request.
> Suppose we have an enum called "Privacy" that we would like to share between multiple
schemas:
> {code}
> //privacy.avsc
> { 
>   "type": "enum",
>   "name": "Privacy",
>   "symbols" : ["Public", "Private"]
> }
> {code}
> Now, if this feature was implemented one could import the above type into other schema
files by doing something like this: 
> {code}
> //the post.avsc 
> {
>   "type": "record", 
>   "name": "Post",
>   "imports": ["privacy.avsc"] //you can import one or more schemas
>   "fields": [{
>               "name": "privacy", 
>               "type": [ "null", "Privacy"], //use imported Privacy type
>               "default": "Private"
>             }
>   ]
> }
> {code}
> Here's another schema file that also has a similar privacy concern:
> {code}
> //the event.avsc is another schema that also imports the privacy type
> {
>   "type": "record", 
>   "name": "Event",
>   "imports": ["privacy.avsc"] //it also imports the privacy schemas
>   "fields": [{
>               "name": "privacy", 
>               "type": [ "null", "Privacy"], //use imported Privacy type
>               "default": "Public"
>             }
>   ]
> }
> {code}
> IDL files are able to import external schemas and protocols and it would be very beneficial
if schema files could import other schema files. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message