Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro >> mail # user >> Schema validation of a field's default values


+
Mark Hayes 2012-10-20, 00:19
Copy link to this message
-
Re: Schema validation of a field's default values
On Fri, Oct 19, 2012 at 5:19 PM, Mark Hayes <[EMAIL PROTECTED]> wrote:
> It looks like the Schema parser doesn't check a field's default value
> against the field's type.  So for example, you can define a string default
> value for a field of type int.  Since the default value is only used in
> certain circumstances for schema resolution, such an error might not easily
> be caught during testing, so the danger is that it would crop up at runtime.
>
> Am I correct, so far?

Yes, that's correct.

> If so, does anyone know of facility in the Avro library, or another library,
> for checking the schema to ensure that default values are of the proper
> type?  I wasn't able to find one, so I'm considering implementing one
> myself.

No, I don't know of a default value validator that's been implemented
yet.  It would be great to have one.

I think this would recursively walk a schema.  Whenever a non-null
default value is found it could call ResolvingGrammarDecoder#encode().
 That's what interprets Json default values.  (Perhaps this logic
should be moved, though.)

Doug
+
Mark Hayes 2012-11-03, 16:48
+
Doug Cutting 2012-11-05, 18:46
+
Mark Hayes 2012-11-05, 21:44
+
Doug Cutting 2012-11-05, 22:01
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB