This is an automated email from the ASF dual-hosted git repository.

pvary pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/branch-3 by this push:
     new 397e2f5  HIVE-24797: Disable validate default values when parsing Avro 
schemas (#2670)
397e2f5 is described below

commit 397e2f530fd7b778399c689ceaf65fbbd6e951f8
Author: Jacob Ilias Komissar <jikomis...@wpi.edu>
AuthorDate: Wed Oct 6 10:57:39 2021 -0400

    HIVE-24797: Disable validate default values when parsing Avro schemas 
(#2670)
---
 .../org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java
index d16abdb..e0e7392 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java
@@ -276,17 +276,20 @@ public class AvroSerdeUtils {
     return dec;
   }
 
+  private static Schema.Parser getSchemaParser() {
+    // HIVE-24797: Disable validate default values when parsing Avro schemas.
+    return new Schema.Parser().setValidateDefaults(false);
+  }
+
   public static Schema getSchemaFor(String str) {
-    Schema.Parser parser = new Schema.Parser();
-    Schema schema = parser.parse(str);
+    Schema schema = getSchemaParser().parse(str);
     return schema;
   }
 
   public static Schema getSchemaFor(File file) {
-    Schema.Parser parser = new Schema.Parser();
     Schema schema;
     try {
-      schema = parser.parse(file);
+      schema = getSchemaParser().parse(file);
     } catch (IOException e) {
       throw new RuntimeException("Failed to parse Avro schema from " + 
file.getName(), e);
     }
@@ -294,10 +297,9 @@ public class AvroSerdeUtils {
   }
 
   public static Schema getSchemaFor(InputStream stream) {
-    Schema.Parser parser = new Schema.Parser();
     Schema schema;
     try {
-      schema = parser.parse(stream);
+      schema = getSchemaParser().parse(stream);
     } catch (IOException e) {
       throw new RuntimeException("Failed to parse Avro schema", e);
     }

Reply via email to