Index: ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (revision 134101) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (working copy) @@ -133,17 +133,25 @@ } /** - * For now, if the user specifies either the map or the collections delimiter, we infer the - * table to DynamicSerDe/TCTLSeparatedProtocol. - * In the future, we should infer this for any delimiters specified, but this will break older - * hive tables, so not for now. + * If the user didn't specify a SerDe, and any of the columns are not of type String, + * we will have to use DynamicSerDe instead. */ - if (crtTbl.getCollItemDelim() != null || crtTbl.getMapKeyDelim() != null) { - tbl.setSerializationLib(org.apache.hadoop.hive.serde2.dynamic_type.DynamicSerDe.class.getName()); - tbl.setSerdeParam(org.apache.hadoop.hive.serde.Constants.SERIALIZATION_FORMAT, org.apache.hadoop.hive.serde2.thrift.TCTLSeparatedProtocol.class.getName()); + if (crtTbl.getSerName() == null) { + boolean useDynamicSerDe = false; + if (crtTbl.getCols() != null) { + for (FieldSchema field: crtTbl.getCols()) { + if (!Constants.STRING_TYPE_NAME.equalsIgnoreCase(field.getType())) { + useDynamicSerDe = true; + } + } + } + if (useDynamicSerDe) { + LOG.info("Default to DynamicSerDe for table " + crtTbl.getTableName() ); + tbl.setSerializationLib(org.apache.hadoop.hive.serde2.dynamic_type.DynamicSerDe.class.getName()); + tbl.setSerdeParam(org.apache.hadoop.hive.serde.Constants.SERIALIZATION_FORMAT, org.apache.hadoop.hive.serde2.thrift.TCTLSeparatedProtocol.class.getName()); + } } - if (crtTbl.getComment() != null) tbl.setProperty("comment", crtTbl.getComment()); if (crtTbl.getLocation() != null) Index: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (revision 134101) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (working copy) @@ -3417,7 +3417,8 @@ desc = new exprNodeIndexDesc(t, children.get(0), children.get(1)); } else { - throw new SemanticException(ErrorMsg.NON_COLLECTION_TYPE.getMsg(expr)); + throw new SemanticException(ErrorMsg.NON_COLLECTION_TYPE.getMsg(expr, + myt.getTypeName())); } } else { // other operators or functions