Index: ql/src/test/results/clientpositive/create_1.q.out =================================================================== --- ql/src/test/results/clientpositive/create_1.q.out (revision 0) +++ ql/src/test/results/clientpositive/create_1.q.out (revision 0) @@ -0,0 +1,18 @@ +a string +b string +a string +b string +Detailed Table Information: +Table(tableName:table1,dbName:default,owner:zshao,createTime:1228887062,lastAccessTime:0,retention:0,sd:StorageDescriptor(cols:[FieldSchema(name:a,type:string,comment:null), FieldSchema(name:b,type:string,comment:null)],location:file:/data/users/zshao/sync/apache-trunk/build/ql/test/data/warehouse/table1,inputFormat:org.apache.hadoop.mapred.TextInputFormat,outputFormat:org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat,compressed:false,numBuckets:-1,serdeInfo:SerDeInfo(name:null,serializationLib:org.apache.hadoop.hive.serde2.MetadataTypedColumnsetSerDe,parameters:{serialization.format=1}),bucketCols:[],sortCols:[],parameters:{}),partitionKeys:[],parameters:{}) +a string +b int +a string +b int +Detailed Table Information: +Table(tableName:table2,dbName:default,owner:zshao,createTime:1228887063,lastAccessTime:0,retention:0,sd:StorageDescriptor(cols:[FieldSchema(name:a,type:string,comment:null), FieldSchema(name:b,type:int,comment:null)],location:file:/data/users/zshao/sync/apache-trunk/build/ql/test/data/warehouse/table2,inputFormat:org.apache.hadoop.mapred.TextInputFormat,outputFormat:org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat,compressed:false,numBuckets:-1,serdeInfo:SerDeInfo(name:null,serializationLib:org.apache.hadoop.hive.serde2.dynamic_type.DynamicSerDe,parameters:{serialization.format=org.apache.hadoop.hive.serde2.thrift.TCTLSeparatedProtocol}),bucketCols:[],sortCols:[],parameters:{}),partitionKeys:[],parameters:{}) +a string +b string +a string +b string +Detailed Table Information: +Table(tableName:table3,dbName:default,owner:zshao,createTime:1228887063,lastAccessTime:0,retention:0,sd:StorageDescriptor(cols:[FieldSchema(name:a,type:string,comment:null), FieldSchema(name:b,type:string,comment:null)],location:file:/data/users/zshao/sync/apache-trunk/build/ql/test/data/warehouse/table3,inputFormat:org.apache.hadoop.mapred.TextInputFormat,outputFormat:org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat,compressed:false,numBuckets:-1,serdeInfo:SerDeInfo(name:null,serializationLib:org.apache.hadoop.hive.serde2.MetadataTypedColumnsetSerDe,parameters:{serialization.format=9,field.delim= }),bucketCols:[],sortCols:[],parameters:{}),partitionKeys:[],parameters:{}) Index: ql/src/test/queries/clientpositive/create_1.q =================================================================== --- ql/src/test/queries/clientpositive/create_1.q (revision 0) +++ ql/src/test/queries/clientpositive/create_1.q (revision 0) @@ -0,0 +1,17 @@ +DROP TABLE table1; +CREATE TABLE table1 (a STRING, b STRING) STORED AS TEXTFILE; +DESCRIBE table1; +DESCRIBE EXTENDED table1; + +DROP TABLE table2; +CREATE TABLE table2 (a STRING, b INT) STORED AS TEXTFILE; +DESCRIBE table2; +DESCRIBE EXTENDED table2; + +DROP TABLE table3; +CREATE TABLE table3 (a STRING, b STRING) +ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' +STORED AS TEXTFILE; +DESCRIBE table3; +DESCRIBE EXTENDED table3; + Index: ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (revision 724941) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (working copy) @@ -524,19 +524,23 @@ } /** - * 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) Index: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (revision 724941) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (working copy) @@ -3434,7 +3434,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