You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Warren Crossing (JIRA)" <ji...@apache.org> on 2018/08/19 02:00:03 UTC

[jira] [Commented] (AVRO-1764) Allow YAML files as Map to be added in RecordSchema

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

Warren Crossing commented on AVRO-1764:
---------------------------------------

I would like to define my avsc schemas using yaml, which is what this patch does right?

I think JSON is a legacy format that's only useful in a javascript eval environment.  YML is better for humans and editors.

I would like to see full yaml support in later versions of avro.

> Allow YAML files as Map to be added in RecordSchema
> ---------------------------------------------------
>
>                 Key: AVRO-1764
>                 URL: https://issues.apache.org/jira/browse/AVRO-1764
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.9.0
>            Reporter: Tiago Lima
>            Priority: Major
>
> I did this little improvement to allow me to add annotations to generated files. 
> So, if I want to add persistence's annotation to the generated files, I will have to add some "javaAnnotations` in schema. This is a bad idea, because my client also will have these annotations. Maybe I just have to create a *new layer* using the *Decorator Pattern* to add those annotations, but I don't want this level of complexity in my application. I just want that my Avro Objects have some custom annotations.
> Because of that, we should have the opportunity to add custom configuration to be accessed via velocity template (record.vm). So, I added an attribute in RecordSchema (called metadata) that read an YAML file, which has the same name of the Record, to be loaded as a Map. Now, I just have to overwrite the record.vm from velocity to call metadata.
> {code:title=record.vm|borderStyle=solid}
> #set ($indexName = $schema.getMetadata().get('persistence').get('elasticsearch').get('indexName'))
> #set ($type = $schema.getMetadata().get('persistence').get('elasticsearch').get('type'))
> @Document(indexName = "$indexName", type = "$type")
> {code}
> This can also be used to add validations and any kind of behaviour to the Avro Object.
> I just opened a PR that is just a preview of a solution.
> Thanks.



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