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

Zoltan Farkas commented on AVRO-2742:
-------------------------------------

Well the schema parser, explicitly allows to disable name validation 
(https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/Schema.java#L1331):

{code}
    /** Enable or disable name validation. */
    public Parser setValidate(boolean validate) {
      this.validate = validate;
      return this;
    }
{code}

I am not sure why the implementation allows this, but let me give an example of 
where I use avro with name validation disabled:

When  playing around with avro as a "frontend" for apache calcite, I was 
converting a calcite result-set row to a avro record, the following query 
resultset would not be possible to easily represent in avro:

https://demo.spf4j.org/avql/query?query=select%20originPlanet,count(*)%20as%20nrSpecies,sum(averageLifeSpanYears)/count(*)%20from%20species%20group%20by%20originPlanet

one could work around it with "as":

https://demo.spf4j.org/avql/query?query=select%20originPlanet,count(*)%20as%20nrSpecies,sum(averageLifeSpanYears)/count(*)%20as%20avgLifeSpanYears%20from%20species%20group%20by%20originPlanet

The naming restrictions are useful only when generating specific records. But 
not every use case needs them.

for more background on my experiment see: 
https://github.com/zolyfarkas/jaxrs-spf4j-demo/wiki/AvroCalciteRest

Another thing is aliases, I am not sure what the spec says about them, but they 
are not validated at all...


> Schema.Parser.parse() does not validate namespace
> -------------------------------------------------
>
>                 Key: AVRO-2742
>                 URL: https://issues.apache.org/jira/browse/AVRO-2742
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.9.2
>            Reporter: radai rosenblatt
>            Priority: Major
>
> [the spec|https://avro.apache.org/docs/current/spec.html#names] has the 
> following to say about names:
> {quote}The name portion of a fullname, record field names, and enum symbols 
> must: ... A namespace is a dot-separated sequence of such names.
> {quote}
> and yet the following schema parses just fine for me:
> {code:java}
> {
>   "type": "record",
>   "namespace": "this thing. has spaces.in it?!",
>   "name": "HasInvalidNamespace",
>   "fields": [
>     {
>       "name": "stringField",
>       "type": "string"
>     }
>   ]
> }
> {code}
> am I misunderstanding the spec? also, even if this is technically a legal 
> schema it will never survive code generation of specific record classes (at 
> least in java?)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to