[jira] [Commented] (AVRO-2366) setValidateDefaults=false does not seem to work

2020-05-19 Thread Ryan Skraba (Jira)


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

Ryan Skraba commented on AVRO-2366:
---

Hello!  This code works:

{code}
Schema schema = new Schema.Parser().setValidateDefaults(false).parse(
  "{\"type\": \"record\", \"name\": \"a\"," +
" \"fields\":[ {\"name\": \"name\", \"type\": \"string\", \"default\": 
null}]}"
);
{code}

It looks like you would need a configuration option to the maven-avro-plugin to 
use the above schema, which was (unfortunately) accepted in Avro 1.8.x.  *If 
possible*, I strongly recommend fixing the schema to have a valid default 
value!  It looks like {{setValidateDefaults()}} works as intended, but there's 
a discussion at AVRO-2817 to find other use cases that need to parse the faulty 
schemas that Java allowed up to this point.

Related: it looks like the upstream gradle-avro-plugin repo that the sample 
groovy test case forks has been bumped to Avro 1.9 and has removed the 
validateDefault option.

> setValidateDefaults=false does not seem to work
> ---
>
> Key: AVRO-2366
> URL: https://issues.apache.org/jira/browse/AVRO-2366
> Project: Apache Avro
>  Issue Type: Bug
>Affects Versions: 1.9.0
>Reporter: Raman Gupta
>Priority: Major
>
> Followup to AVRO-2035.
> I am testing 1.9 SNAPSHOT. I set `Schema.Parser.setValidateDefaults` to 
> false, and still get a failure at compile-time if the default does not match 
> the schema. For example, a field definition of:
> {"name": "name", "type": "string", "default": null}
> Should this definition succeed if `setValidateDefaults(false)` is called? If 
> not, should the `setValidateDefaults` method just be removed?
> The exception is:
> Caused by: org.apache.avro.AvroTypeException: Invalid default for field name: 
> null not a {"type":"string","avro.java.string":"String"}
>   at org.apache.avro.Schema.validateDefault(Schema.java:1482)
>   at org.apache.avro.Schema.access$300(Schema.java:84)
>   at org.apache.avro.Schema$Field.(Schema.java:493)
>   at org.apache.avro.Schema$Field.(Schema.java:485)
>   at org.apache.avro.Schema$Field.(Schema.java:504)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:689)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:668)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.compile(SpecificCompiler.java:598)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.compileToDestination(SpecificCompiler.java:527)



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


[jira] [Commented] (AVRO-2366) setValidateDefaults=false does not seem to work

2019-04-28 Thread Rumeshkrishnan (JIRA)


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

Rumeshkrishnan commented on AVRO-2366:
--

HI [~rocketraman] , I created patch for avro [https://github.com/apache/avro]. 
I hope this will help to fix the issue. Can you test with this patch. Let me 
know. I will create the pull request. 

> setValidateDefaults=false does not seem to work
> ---
>
> Key: AVRO-2366
> URL: https://issues.apache.org/jira/browse/AVRO-2366
> Project: Apache Avro
>  Issue Type: Bug
>Affects Versions: 1.9.0
>Reporter: Raman Gupta
>Priority: Major
> Attachments: AVRO-2366_fix_setValidateDefaults.patch
>
>
> Followup to AVRO-2035.
> I am testing 1.9 SNAPSHOT. I set `Schema.Parser.setValidateDefaults` to 
> false, and still get a failure at compile-time if the default does not match 
> the schema. For example, a field definition of:
> {"name": "name", "type": "string", "default": null}
> Should this definition succeed if `setValidateDefaults(false)` is called? If 
> not, should the `setValidateDefaults` method just be removed?
> The exception is:
> Caused by: org.apache.avro.AvroTypeException: Invalid default for field name: 
> null not a {"type":"string","avro.java.string":"String"}
>   at org.apache.avro.Schema.validateDefault(Schema.java:1482)
>   at org.apache.avro.Schema.access$300(Schema.java:84)
>   at org.apache.avro.Schema$Field.(Schema.java:493)
>   at org.apache.avro.Schema$Field.(Schema.java:485)
>   at org.apache.avro.Schema$Field.(Schema.java:504)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:689)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:668)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.compile(SpecificCompiler.java:598)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.compileToDestination(SpecificCompiler.java:527)



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


[jira] [Commented] (AVRO-2366) setValidateDefaults=false does not seem to work

2019-04-27 Thread Raman Gupta (JIRA)


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

Raman Gupta commented on AVRO-2366:
---

Thanks [~rumeshkrish]... you can see the problem by checking out commit 
3d2666f760b4834bcfdf2d2a96d6a277972d24c7 of  
https://github.com/rocketraman/gradle-avro-plugin 
(https://github.com/rocketraman/gradle-avro-plugin/tree/3d2666f760b4834bcfdf2d2a96d6a277972d24c7).

The failing test case, that worked on 1.8.0, is this one here -- just remove 
the @Ignored annotation:

https://github.com/rocketraman/gradle-avro-plugin/blob/3d2666f760b4834bcfdf2d2a96d6a277972d24c7/src/test/groovy/com/commercehub/gradle/plugin/avro/OptionsFunctionalSpec.groovy#L293

> setValidateDefaults=false does not seem to work
> ---
>
> Key: AVRO-2366
> URL: https://issues.apache.org/jira/browse/AVRO-2366
> Project: Apache Avro
>  Issue Type: Bug
>Affects Versions: 1.9.0
>Reporter: Raman Gupta
>Priority: Major
>
> Followup to AVRO-2035.
> I am testing 1.9 SNAPSHOT. I set `Schema.Parser.setValidateDefaults` to 
> false, and still get a failure at compile-time if the default does not match 
> the schema. For example, a field definition of:
> {"name": "name", "type": "string", "default": null}
> Should this definition succeed if `setValidateDefaults(false)` is called? If 
> not, should the `setValidateDefaults` method just be removed?
> The exception is:
> Caused by: org.apache.avro.AvroTypeException: Invalid default for field name: 
> null not a {"type":"string","avro.java.string":"String"}
>   at org.apache.avro.Schema.validateDefault(Schema.java:1482)
>   at org.apache.avro.Schema.access$300(Schema.java:84)
>   at org.apache.avro.Schema$Field.(Schema.java:493)
>   at org.apache.avro.Schema$Field.(Schema.java:485)
>   at org.apache.avro.Schema$Field.(Schema.java:504)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:689)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:668)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.compile(SpecificCompiler.java:598)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.compileToDestination(SpecificCompiler.java:527)



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


[jira] [Commented] (AVRO-2366) setValidateDefaults=false does not seem to work

2019-04-26 Thread Rumeshkrishnan (JIRA)


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

Rumeshkrishnan commented on AVRO-2366:
--

Hi [~rocketraman], Can you give me sample test case ? I will help you to fix 
this.

> setValidateDefaults=false does not seem to work
> ---
>
> Key: AVRO-2366
> URL: https://issues.apache.org/jira/browse/AVRO-2366
> Project: Apache Avro
>  Issue Type: Bug
>Affects Versions: 1.9.0
>Reporter: Raman Gupta
>Priority: Major
>
> Followup to AVRO-2035.
> I am testing 1.9 SNAPSHOT. I set `Schema.Parser.setValidateDefaults` to 
> false, and still get a failure at compile-time if the default does not match 
> the schema. For example, a field definition of:
> {"name": "name", "type": "string", "default": null}
> Should this definition succeed if `setValidateDefaults(false)` is called? If 
> not, should the `setValidateDefaults` method just be removed?
> The exception is:
> Caused by: org.apache.avro.AvroTypeException: Invalid default for field name: 
> null not a {"type":"string","avro.java.string":"String"}
>   at org.apache.avro.Schema.validateDefault(Schema.java:1482)
>   at org.apache.avro.Schema.access$300(Schema.java:84)
>   at org.apache.avro.Schema$Field.(Schema.java:493)
>   at org.apache.avro.Schema$Field.(Schema.java:485)
>   at org.apache.avro.Schema$Field.(Schema.java:504)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:689)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.addStringType(SpecificCompiler.java:668)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.compile(SpecificCompiler.java:598)
>   at 
> org.apache.avro.compiler.specific.SpecificCompiler.compileToDestination(SpecificCompiler.java:527)



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