You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by zh...@apache.org on 2023/12/06 15:38:26 UTC
(hive) branch master updated: HIVE-27935: Add qtest for Avro invalid schema and field names (#4918) (Akshat Mathur, reviewed by Butao Zhang)
This is an automated email from the ASF dual-hosted git repository.
zhangbutao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 60b1de1a05c HIVE-27935: Add qtest for Avro invalid schema and field names (#4918) (Akshat Mathur, reviewed by Butao Zhang)
60b1de1a05c is described below
commit 60b1de1a05c18156f597ac36f2b702e930b26e40
Author: Akshat Mathur <ak...@gmail.com>
AuthorDate: Wed Dec 6 21:08:19 2023 +0530
HIVE-27935: Add qtest for Avro invalid schema and field names (#4918) (Akshat Mathur, reviewed by Butao Zhang)
---
.../clientnegative/avro_duplicate_field_name.q | 25 ++++++++++++++++++++
.../clientnegative/avro_invalid_field_name.q | 18 +++++++++++++++
.../clientnegative/avro_duplicate_field_name.q.out | 27 ++++++++++++++++++++++
.../clientnegative/avro_invalid_field_name.q.out | 20 ++++++++++++++++
4 files changed, 90 insertions(+)
diff --git a/ql/src/test/queries/clientnegative/avro_duplicate_field_name.q b/ql/src/test/queries/clientnegative/avro_duplicate_field_name.q
new file mode 100644
index 00000000000..d10af6c1506
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/avro_duplicate_field_name.q
@@ -0,0 +1,25 @@
+-- verify AVRO-3827: Disallow duplicate field names
+
+CREATE TABLE avroExternalDupField
+STORED AS AVRO
+TBLPROPERTIES ('avro.schema.literal'='{
+ "namespace": "org.apache.hive",
+ "name": "my_schema",
+ "type": "record",
+ "fields": [
+ {
+ "name": "f1",
+ "type": {
+ "name": "a",
+ "type": "record",
+ "fields": []
+ }
+ }, {
+ "name": "f1",
+ "type": {
+ "name": "b",
+ "type": "record",
+ "fields": []
+ }
+ }
+ ] }');
diff --git a/ql/src/test/queries/clientnegative/avro_invalid_field_name.q b/ql/src/test/queries/clientnegative/avro_invalid_field_name.q
new file mode 100644
index 00000000000..8ce42bc3dbf
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/avro_invalid_field_name.q
@@ -0,0 +1,18 @@
+-- verify AVRO-3820:Don't allow invalid field names, field name should match [A-Za-z_][A-Za-z0-9_]*
+
+CREATE TABLE avroExternalInvalidField
+STORED AS AVRO
+TBLPROPERTIES ('avro.schema.literal'='{
+ "namespace": "org.apache.hive",
+ "name": "my_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "f1.x",
+ "type": {
+ "name": "my_enum",
+ "type": "enum",
+ "symbols": ["a"]
+ }
+ }
+ ] }');
diff --git a/ql/src/test/results/clientnegative/avro_duplicate_field_name.q.out b/ql/src/test/results/clientnegative/avro_duplicate_field_name.q.out
new file mode 100644
index 00000000000..3d7527c33a0
--- /dev/null
+++ b/ql/src/test/results/clientnegative/avro_duplicate_field_name.q.out
@@ -0,0 +1,27 @@
+PREHOOK: query: CREATE TABLE avroExternalDupField
+STORED AS AVRO
+TBLPROPERTIES ('avro.schema.literal'='{
+ "namespace": "org.apache.hive",
+ "name": "my_schema",
+ "type": "record",
+ "fields": [
+ {
+ "name": "f1",
+ "type": {
+ "name": "a",
+ "type": "record",
+ "fields": []
+ }
+ }, {
+ "name": "f1",
+ "type": {
+ "name": "b",
+ "type": "record",
+ "fields": []
+ }
+ }
+ ] }')
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@avroExternalDupField
+FAILED: Execution Error, return code 40000 from org.apache.hadoop.hive.ql.ddl.DDLTask. java.lang.RuntimeException: MetaException(message:org.apache.hadoop.hive.serde2.SerDeException Invalid schema reported)
diff --git a/ql/src/test/results/clientnegative/avro_invalid_field_name.q.out b/ql/src/test/results/clientnegative/avro_invalid_field_name.q.out
new file mode 100644
index 00000000000..75ae3f4e8d3
--- /dev/null
+++ b/ql/src/test/results/clientnegative/avro_invalid_field_name.q.out
@@ -0,0 +1,20 @@
+PREHOOK: query: CREATE TABLE avroExternalInvalidField
+STORED AS AVRO
+TBLPROPERTIES ('avro.schema.literal'='{
+ "namespace": "org.apache.hive",
+ "name": "my_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "f1.x",
+ "type": {
+ "name": "my_enum",
+ "type": "enum",
+ "symbols": ["a"]
+ }
+ }
+ ] }')
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@avroExternalInvalidField
+FAILED: Execution Error, return code 40000 from org.apache.hadoop.hive.ql.ddl.DDLTask. java.lang.RuntimeException: MetaException(message:org.apache.hadoop.hive.serde2.SerDeException Invalid schema reported)