diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java b/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java index 432f7d0..11a10f0 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java @@ -80,6 +80,7 @@ import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; import org.apache.hadoop.hive.shims.ShimLoader; import org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge; +import org.apache.hive.common.util.HiveStringUtils; import org.apache.hive.common.util.ReflectionUtil; import javax.annotation.Nullable; @@ -1764,4 +1765,15 @@ public static String encodeTableName(String name) { return ret; } + // mainly for HBase store. For example, HBase store will directly store + // colnames with upperCases. + public static List normalizeFieldSchemaList(List fieldschemas) { + List ret = new ArrayList<>(); + for (FieldSchema fieldSchema : fieldschemas) { + ret.add(new FieldSchema(HiveStringUtils.normalizeIdentifier(fieldSchema.getName()), + fieldSchema.getType(), fieldSchema.getComment())); + } + return ret; + } + } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java index deec8bb..30dd852 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java @@ -3901,7 +3901,7 @@ private int createTable(Hive db, CreateTableDesc crtTbl) throws HiveException { } if (crtTbl.getPartCols() != null) { - tbl.setPartCols(crtTbl.getPartCols()); + tbl.setPartCols(MetaStoreUtils.normalizeFieldSchemaList(crtTbl.getPartCols())); } if (crtTbl.getNumBuckets() != -1) { tbl.setNumBuckets(crtTbl.getNumBuckets()); @@ -3964,7 +3964,7 @@ private int createTable(Hive db, CreateTableDesc crtTbl) throws HiveException { } if (crtTbl.getCols() != null) { - tbl.setFields(crtTbl.getCols()); + tbl.setFields(MetaStoreUtils.normalizeFieldSchemaList(crtTbl.getCols())); } if (crtTbl.getBucketCols() != null) { tbl.setBucketCols(crtTbl.getBucketCols());