From 5e497c64c2810b6c3674204c19b100bebfb13d22 Mon Sep 17 00:00:00 2001 From: shivjha Date: Tue, 22 Oct 2024 10:30:24 +0530 Subject: [PATCH] [HIVE-28585]: Ensure SerDes is case insensitive for data type-'string' to align with HQL and SQL --- .../primitive/PrimitiveObjectInspectorUtils.java | 2 +- .../apache/hadoop/hive/serde2/TestOpenCSVSerde.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java b/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java index c61b4c3c581c..c595fdb8e543 100644 --- a/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java +++ b/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/PrimitiveObjectInspectorUtils.java @@ -384,7 +384,7 @@ public static PrimitiveTypeEntry getTypeEntryFromPrimitiveWritableClass( * Get the TypeEntry for the given base type name (int, varchar, etc). */ public static PrimitiveTypeEntry getTypeEntryFromTypeName(String typeName) { - return typeNameToTypeEntry.get(typeName); + return typeNameToTypeEntry.get(typeName.toLowerCase()); } /** diff --git a/serde/src/test/org/apache/hadoop/hive/serde2/TestOpenCSVSerde.java b/serde/src/test/org/apache/hadoop/hive/serde2/TestOpenCSVSerde.java index 7bba591f7e99..f4aa949777ca 100644 --- a/serde/src/test/org/apache/hadoop/hive/serde2/TestOpenCSVSerde.java +++ b/serde/src/test/org/apache/hadoop/hive/serde2/TestOpenCSVSerde.java @@ -39,6 +39,18 @@ public void setup() throws Exception { props.setProperty(serdeConstants.LIST_COLUMN_TYPES, "string,string,string"); } + + @Test + public void testColumnDeserializeCase() throws Exception { + props.setProperty(serdeConstants.LIST_COLUMN_TYPES, "STRING,String,string"); + csv.initialize(null, props, null); + final Text in = new Text("hello,\"yes, okay\",1"); + final List row = (List) csv.deserialize(in); + assertEquals("hello", row.get(0)); + assertEquals("yes, okay", row.get(1)); + assertEquals("1", row.get(2)); + } + @Test public void testDeserialize() throws Exception { csv.initialize(null, props, null);