diff --git a/data/files/schema_break.avro b/data/files/schema_break.avro new file mode 100644 index 0000000..a6c631e Binary files /dev/null and b/data/files/schema_break.avro differ diff --git a/ql/src/test/queries/clientpositive/avro_schema_discrepancy.q b/ql/src/test/queries/clientpositive/avro_schema_discrepancy.q new file mode 100644 index 0000000..cbe05c6 --- /dev/null +++ b/ql/src/test/queries/clientpositive/avro_schema_discrepancy.q @@ -0,0 +1,139 @@ +CREATE TABLE avro_schema_break_1 +ROW FORMAT +SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' +STORED AS +INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' +OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' +TBLPROPERTIES ('avro.schema.literal'='{ + "type": "record", + "name": "Messages", + "namespace": "net.myth", + "fields": [ + { + "name": "header", + "type": [ + "null", + { + "type": "record", + "name": "HeaderInfo", + "fields": [ + { + "name": "inferred_event_type", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "event_type", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "event_version", + "type": [ + "null", + "string" + ], + "default": null + } + ] + } + ] + }, + { + "name": "messages", + "type": { + "type": "array", + "items": { + "name": "MessageInfo", + "type": "record", + "fields": [ + { + "name": "message_id", + "type": [ + "null", + "string" + ], + "doc": "Message-ID" + }, + { + "name": "received_date", + "type": [ + "null", + "long" + ], + "doc": "Received Date" + }, + { + "name": "sent_date", + "type": [ + "null", + "long" + ] + }, + { + "name": "from_name", + "type": [ + "null", + "string" + ] + }, + { + "name": "flags", + "type": [ + "null", + { + "type": "record", + "name": "Flags", + "fields": [ + { + "name": "is_seen", + "type": [ + "null", + "boolean" + ], + "default": null + }, + { + "name": "is_read", + "type": [ + "null", + "boolean" + ], + "default": null + }, + { + "name": "is_flagged", + "type": [ + "null", + "boolean" + ], + "default": null + } + ] + } + ], + "default": null + } + ] + } + } + } + ] +}'); + +LOAD DATA LOCAL INPATH '../../data/files/schema_break.avro' OVERWRITE INTO TABLE avro_schema_break_1; + +SELECT * FROM avro_schema_break_1; + +CREATE TABLE avro_schema_break_2 LIKE avro_schema_break_1; +LOAD DATA LOCAL INPATH '../../data/files/schema_break.avro' OVERWRITE INTO TABLE avro_schema_break_2; +ALTER TABLE avro_schema_break_2 UNSET TBLPROPERTIES( 'avro.schema.literal' ) ; + +SELECT * FROM avro_schema_break_2; +