diff --git a/data/files/test_schema1.avsc b/data/files/test_schema1.avsc new file mode 100644 index 00000000000..380f13f8703 --- /dev/null +++ b/data/files/test_schema1.avsc @@ -0,0 +1,12 @@ +{ + "type":"record", + "name":"test_schema", + "namespace":"gdc_datascience_qa", + "fields":[ + { + "name":"name", + "type":[ "null", "string"], + "default":null + } + ] +} \ No newline at end of file diff --git a/data/files/test_schema2.avsc b/data/files/test_schema2.avsc new file mode 100644 index 00000000000..ac6c5f995fd --- /dev/null +++ b/data/files/test_schema2.avsc @@ -0,0 +1,20 @@ +{ + "type":"record", + "name":"test_schema", + "namespace":"gdc_datascience_qa", + "fields":[ + { + "name":"name", + "type":["null","string"], + "default":null + }, + { + "name":"last_name", + "type":[ + "null", + "string" + ], + "default":null + } + ] +} \ No newline at end of file diff --git a/ql/src/test/queries/clientpositive/avro_alter_schema.q b/ql/src/test/queries/clientpositive/avro_alter_schema.q new file mode 100644 index 00000000000..9c3246f30c6 --- /dev/null +++ b/ql/src/test/queries/clientpositive/avro_alter_schema.q @@ -0,0 +1,15 @@ +set hive.stats.column.autogather=true; + +dfs -cp ${system:hive.root}data/files/test_schema1.avsc ${system:test.tmp.dir}/test_schema1.avsc; +dfs -cp ${system:hive.root}data/files/test_schema2.avsc ${system:test.tmp.dir}/test_schema2.avsc; + +create external table t1 stored as avro tblproperties ('avro.schema.url'='${system:test.tmp.dir}/test_schema1.avsc'); + +alter table t1 set tblproperties('avro.schema.url'='${system:test.tmp.dir}/test_schema2.avsc'); +insert into t1 values ('n1', 'l1'); + +create external table t2 stored as avro tblproperties ('avro.schema.url'='${system:test.tmp.dir}/test_schema2.avsc'); + +insert into t2 values ('n2', 'l2'); + +insert overwrite table t1 select * from t2; \ No newline at end of file