Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport to 3: HIVE-24797: Disable validate default values when parsing Avro schemas #2670

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -276,28 +276,30 @@ public static HiveDecimal getHiveDecimalFromByteBuffer(ByteBuffer byteBuffer, in
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);
}
return schema;
}

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);
}
Expand Down