deniskuzZ commented on PR #6619:
URL: https://github.com/apache/hive/pull/6619#issuecomment-5034524619
please create a unit test, i think q test is an overkill
````
Subject: [PATCH] patch
---
Index:
serde/src/test/org/apache/hadoop/hive/serde2/typeinfo/TestTypeInfoUtils.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git
a/serde/src/test/org/apache/hadoop/hive/serde2/typeinfo/TestTypeInfoUtils.java
b/serde/src/test/org/apache/hadoop/hive/serde2/typeinfo/TestTypeInfoUtils.java
---
a/serde/src/test/org/apache/hadoop/hive/serde2/typeinfo/TestTypeInfoUtils.java
(revision ef821c2a22ffdddc56e0280a33356878abbce04c)
+++
b/serde/src/test/org/apache/hadoop/hive/serde2/typeinfo/TestTypeInfoUtils.java
(date 1784639442922)
@@ -20,6 +20,7 @@
+import java.util.Arrays;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
import static org.junit.Assert.assertEquals;
@@ -125,4 +126,43 @@
assertEquals("Failed for " + testCase.typeString,
testCase.expectedScale, decimalType.getScale());
}
}
+
+ @Test
+ public void testStructFieldNameWithSpecialChars() {
+ TypeInfo typeInfo =
TypeInfoUtils.getTypeInfoFromTypeString("struct<gpa_!@#$%^&*():double>");
+ StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo;
+ assertEquals(1, structTypeInfo.getAllStructFieldNames().size());
+ assertEquals("gpa_!@#$%^&*()",
structTypeInfo.getAllStructFieldNames().get(0));
+ assertEquals(TypeInfoFactory.doubleTypeInfo,
structTypeInfo.getAllStructFieldTypeInfos().get(0));
+ }
+
+ @Test
+ public void testStructFieldNameStartingWithSpecialChar() {
+ TypeInfo typeInfo =
TypeInfoUtils.getTypeInfoFromTypeString("struct<!@#$%^&*()_age:int>");
+ StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo;
+ assertEquals(Arrays.asList("!@#$%^&*()_age"),
structTypeInfo.getAllStructFieldNames());
+ }
+
+ @Test
+ public void testStructMultipleFieldsWithSpecialChars() {
+ TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(
+ "struct<name:string,!@#$%^&*()_age:int,gpa_!@#$%^&*():double>");
+ StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo;
+ assertEquals(Arrays.asList("name", "!@#$%^&*()_age", "gpa_!@#$%^&*()"),
+ structTypeInfo.getAllStructFieldNames());
+ }
+
+ @Test
+ public void testEmptyStruct() {
+ TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString("struct<>");
+ StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo;
+ assertEquals(0, structTypeInfo.getAllStructFieldNames().size());
+ }
+
+ @Test
+ public void testStructTrailingComma() {
+ TypeInfo typeInfo =
TypeInfoUtils.getTypeInfoFromTypeString("struct<a:int,>");
+ StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo;
+ assertEquals(Arrays.asList("a"),
structTypeInfo.getAllStructFieldNames());
+ }
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]