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

HIVE-24436: Fix Avro NULL_DEFAULT_VALUE compatibility issue #1715

Closed
wants to merge 2 commits into from
Closed
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 @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hive.serde2.avro;

import org.apache.avro.JsonProperties;
import org.apache.avro.Schema;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.typeinfo.CharTypeInfo;
Expand Down Expand Up @@ -73,7 +74,7 @@ public Schema convert(List<String> columnNames, List<TypeInfo> columnTypes,
}

private Schema.Field createAvroField(String name, TypeInfo typeInfo, String comment) {
return new Schema.Field(name, createAvroSchema(typeInfo), comment, null);
return new Schema.Field(name, createAvroSchema(typeInfo), comment, JsonProperties.NULL_VALUE);
}
Comment on lines +77 to 78
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


private Schema createAvroSchema(TypeInfo typeInfo) {
Expand Down Expand Up @@ -235,7 +236,7 @@ private Schema createAvroArray(TypeInfo typeInfo) {
private List<Schema.Field> getFields(Schema.Field schemaField) {
List<Schema.Field> fields = new ArrayList<Schema.Field>();

JsonNode nullDefault = JsonNodeFactory.instance.nullNode();
JsonProperties.Null nullDefault = JsonProperties.NULL_VALUE;
if (schemaField.schema().getType() == Schema.Type.RECORD) {
for (Schema.Field field : schemaField.schema().getFields()) {
fields.add(new Schema.Field(field.name(), field.schema(), field.doc(), nullDefault));
Expand Down