Index: ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (revision 1587652) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (working copy) @@ -3652,6 +3652,10 @@ if (alterTbl.getSerdeName() != null) { part.getTPartition().getSd().getSerdeInfo().setSerializationLib( alterTbl.getSerdeName()); + } else { + LOG.info("Default to LazySimpleSerDe for partition"); + part.getTPartition().getSd().getSerdeInfo().setSerializationLib( + org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.class.getName()); } } else { tbl.getTTable().getSd().setInputFormat(alterTbl.getInputFormat()); @@ -3658,6 +3662,10 @@ tbl.getTTable().getSd().setOutputFormat(alterTbl.getOutputFormat()); if (alterTbl.getSerdeName() != null) { tbl.setSerializationLib(alterTbl.getSerdeName()); + } else { + LOG.info("Default to LazySimpleSerDe for table " + tbl.getTableName()); + tbl.setSerializationLib(org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.class + .getName()); } } } else if (alterTbl.getOp() == AlterTableDesc.AlterTableTypes.ALTERPROTECTMODE) { Index: ql/src/test/queries/clientpositive/alter_file_format.q =================================================================== --- ql/src/test/queries/clientpositive/alter_file_format.q (revision 0) +++ ql/src/test/queries/clientpositive/alter_file_format.q (working copy) @@ -0,0 +1,36 @@ +create table alter_file_format_test (key int, value string); +desc FORMATTED alter_file_format_test; + +alter table alter_file_format_test set fileformat rcfile; +desc FORMATTED alter_file_format_test; + +alter table alter_file_format_test set fileformat textfile; +desc FORMATTED alter_file_format_test; + +alter table alter_file_format_test set fileformat rcfile; +desc FORMATTED alter_file_format_test; + +alter table alter_file_format_test set fileformat sequencefile; +desc FORMATTED alter_file_format_test; + +drop table alter_partition_format_test; + +--partitioned table +create table alter_partition_format_test (key int, value string) partitioned by (ds string); + +alter table alter_partition_format_test add partition(ds='2010'); +desc FORMATTED alter_partition_format_test partition(ds='2010'); + +alter table alter_partition_format_test partition(ds='2010') set fileformat rcfile; +desc FORMATTED alter_partition_format_test partition(ds='2010'); + +alter table alter_partition_format_test partition(ds='2010') set fileformat textfile; +desc FORMATTED alter_partition_format_test partition(ds='2010'); + +alter table alter_partition_format_test partition(ds='2010') set fileformat rcfile; +desc FORMATTED alter_partition_format_test partition(ds='2010'); + +alter table alter_partition_format_test partition(ds='2010') set fileformat sequencefile; +desc FORMATTED alter_partition_format_test partition(ds='2010'); + +drop table alter_partition_format_test; \ No newline at end of file Index: ql/src/test/results/clientpositive/alter_file_format.q.out =================================================================== --- ql/src/test/results/clientpositive/alter_file_format.q.out (revision 0) +++ ql/src/test/results/clientpositive/alter_file_format.q.out (working copy) @@ -0,0 +1,486 @@ +PREHOOK: query: create table alter_file_format_test (key int, value string) +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +POSTHOOK: query: create table alter_file_format_test (key int, value string) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@alter_file_format_test +PREHOOK: query: desc FORMATTED alter_file_format_test +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_file_format_test +POSTHOOK: query: desc FORMATTED alter_file_format_test +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_file_format_test +# col_name data_type comment + +key int +value string + +# Detailed Table Information +Database: default +#### A masked pattern was here #### +Protect Mode: None +Retention: 0 +#### A masked pattern was here #### +Table Type: MANAGED_TABLE +Table Parameters: +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe +InputFormat: org.apache.hadoop.mapred.TextInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: alter table alter_file_format_test set fileformat rcfile +PREHOOK: type: ALTERTABLE_FILEFORMAT +PREHOOK: Input: default@alter_file_format_test +PREHOOK: Output: default@alter_file_format_test +POSTHOOK: query: alter table alter_file_format_test set fileformat rcfile +POSTHOOK: type: ALTERTABLE_FILEFORMAT +POSTHOOK: Input: default@alter_file_format_test +POSTHOOK: Output: default@alter_file_format_test +PREHOOK: query: desc FORMATTED alter_file_format_test +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_file_format_test +POSTHOOK: query: desc FORMATTED alter_file_format_test +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_file_format_test +# col_name data_type comment + +key int +value string + +# Detailed Table Information +Database: default +#### A masked pattern was here #### +Protect Mode: None +Retention: 0 +#### A masked pattern was here #### +Table Type: MANAGED_TABLE +Table Parameters: + COLUMN_STATS_ACCURATE false +#### A masked pattern was here #### + numFiles 0 + numRows -1 + rawDataSize -1 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe +InputFormat: org.apache.hadoop.hive.ql.io.RCFileInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.RCFileOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: alter table alter_file_format_test set fileformat textfile +PREHOOK: type: ALTERTABLE_FILEFORMAT +PREHOOK: Input: default@alter_file_format_test +PREHOOK: Output: default@alter_file_format_test +POSTHOOK: query: alter table alter_file_format_test set fileformat textfile +POSTHOOK: type: ALTERTABLE_FILEFORMAT +POSTHOOK: Input: default@alter_file_format_test +POSTHOOK: Output: default@alter_file_format_test +PREHOOK: query: desc FORMATTED alter_file_format_test +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_file_format_test +POSTHOOK: query: desc FORMATTED alter_file_format_test +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_file_format_test +# col_name data_type comment + +key int +value string + +# Detailed Table Information +Database: default +#### A masked pattern was here #### +Protect Mode: None +Retention: 0 +#### A masked pattern was here #### +Table Type: MANAGED_TABLE +Table Parameters: + COLUMN_STATS_ACCURATE false +#### A masked pattern was here #### + numFiles 0 + numRows -1 + rawDataSize -1 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe +InputFormat: org.apache.hadoop.mapred.TextInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: alter table alter_file_format_test set fileformat rcfile +PREHOOK: type: ALTERTABLE_FILEFORMAT +PREHOOK: Input: default@alter_file_format_test +PREHOOK: Output: default@alter_file_format_test +POSTHOOK: query: alter table alter_file_format_test set fileformat rcfile +POSTHOOK: type: ALTERTABLE_FILEFORMAT +POSTHOOK: Input: default@alter_file_format_test +POSTHOOK: Output: default@alter_file_format_test +PREHOOK: query: desc FORMATTED alter_file_format_test +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_file_format_test +POSTHOOK: query: desc FORMATTED alter_file_format_test +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_file_format_test +# col_name data_type comment + +key int +value string + +# Detailed Table Information +Database: default +#### A masked pattern was here #### +Protect Mode: None +Retention: 0 +#### A masked pattern was here #### +Table Type: MANAGED_TABLE +Table Parameters: + COLUMN_STATS_ACCURATE false +#### A masked pattern was here #### + numFiles 0 + numRows -1 + rawDataSize -1 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe +InputFormat: org.apache.hadoop.hive.ql.io.RCFileInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.RCFileOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: alter table alter_file_format_test set fileformat sequencefile +PREHOOK: type: ALTERTABLE_FILEFORMAT +PREHOOK: Input: default@alter_file_format_test +PREHOOK: Output: default@alter_file_format_test +POSTHOOK: query: alter table alter_file_format_test set fileformat sequencefile +POSTHOOK: type: ALTERTABLE_FILEFORMAT +POSTHOOK: Input: default@alter_file_format_test +POSTHOOK: Output: default@alter_file_format_test +PREHOOK: query: desc FORMATTED alter_file_format_test +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_file_format_test +POSTHOOK: query: desc FORMATTED alter_file_format_test +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_file_format_test +# col_name data_type comment + +key int +value string + +# Detailed Table Information +Database: default +#### A masked pattern was here #### +Protect Mode: None +Retention: 0 +#### A masked pattern was here #### +Table Type: MANAGED_TABLE +Table Parameters: + COLUMN_STATS_ACCURATE false +#### A masked pattern was here #### + numFiles 0 + numRows -1 + rawDataSize -1 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe +InputFormat: org.apache.hadoop.mapred.SequenceFileInputFormat +OutputFormat: org.apache.hadoop.mapred.SequenceFileOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: drop table alter_partition_format_test +PREHOOK: type: DROPTABLE +POSTHOOK: query: drop table alter_partition_format_test +POSTHOOK: type: DROPTABLE +PREHOOK: query: --partitioned table +create table alter_partition_format_test (key int, value string) partitioned by (ds string) +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +POSTHOOK: query: --partitioned table +create table alter_partition_format_test (key int, value string) partitioned by (ds string) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@alter_partition_format_test +PREHOOK: query: alter table alter_partition_format_test add partition(ds='2010') +PREHOOK: type: ALTERTABLE_ADDPARTS +PREHOOK: Output: default@alter_partition_format_test +POSTHOOK: query: alter table alter_partition_format_test add partition(ds='2010') +POSTHOOK: type: ALTERTABLE_ADDPARTS +POSTHOOK: Output: default@alter_partition_format_test +POSTHOOK: Output: default@alter_partition_format_test@ds=2010 +PREHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_partition_format_test +POSTHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_partition_format_test +# col_name data_type comment + +key int +value string + +# Partition Information +# col_name data_type comment + +ds string + +# Detailed Partition Information +Partition Value: [2010] +Database: default +Table: alter_partition_format_test +#### A masked pattern was here #### +Protect Mode: None +#### A masked pattern was here #### +Partition Parameters: +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe +InputFormat: org.apache.hadoop.mapred.TextInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: alter table alter_partition_format_test partition(ds='2010') set fileformat rcfile +PREHOOK: type: ALTERPARTITION_FILEFORMAT +PREHOOK: Input: default@alter_partition_format_test +PREHOOK: Output: default@alter_partition_format_test@ds=2010 +POSTHOOK: query: alter table alter_partition_format_test partition(ds='2010') set fileformat rcfile +POSTHOOK: type: ALTERPARTITION_FILEFORMAT +POSTHOOK: Input: default@alter_partition_format_test +POSTHOOK: Input: default@alter_partition_format_test@ds=2010 +POSTHOOK: Output: default@alter_partition_format_test@ds=2010 +PREHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_partition_format_test +POSTHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_partition_format_test +# col_name data_type comment + +key int +value string + +# Partition Information +# col_name data_type comment + +ds string + +# Detailed Partition Information +Partition Value: [2010] +Database: default +Table: alter_partition_format_test +#### A masked pattern was here #### +Protect Mode: None +#### A masked pattern was here #### +Partition Parameters: + COLUMN_STATS_ACCURATE false +#### A masked pattern was here #### + numFiles 0 + numRows -1 + rawDataSize -1 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe +InputFormat: org.apache.hadoop.hive.ql.io.RCFileInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.RCFileOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: alter table alter_partition_format_test partition(ds='2010') set fileformat textfile +PREHOOK: type: ALTERPARTITION_FILEFORMAT +PREHOOK: Input: default@alter_partition_format_test +PREHOOK: Output: default@alter_partition_format_test@ds=2010 +POSTHOOK: query: alter table alter_partition_format_test partition(ds='2010') set fileformat textfile +POSTHOOK: type: ALTERPARTITION_FILEFORMAT +POSTHOOK: Input: default@alter_partition_format_test +POSTHOOK: Input: default@alter_partition_format_test@ds=2010 +POSTHOOK: Output: default@alter_partition_format_test@ds=2010 +PREHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_partition_format_test +POSTHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_partition_format_test +# col_name data_type comment + +key int +value string + +# Partition Information +# col_name data_type comment + +ds string + +# Detailed Partition Information +Partition Value: [2010] +Database: default +Table: alter_partition_format_test +#### A masked pattern was here #### +Protect Mode: None +#### A masked pattern was here #### +Partition Parameters: + COLUMN_STATS_ACCURATE false +#### A masked pattern was here #### + numFiles 0 + numRows -1 + rawDataSize -1 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe +InputFormat: org.apache.hadoop.mapred.TextInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: alter table alter_partition_format_test partition(ds='2010') set fileformat rcfile +PREHOOK: type: ALTERPARTITION_FILEFORMAT +PREHOOK: Input: default@alter_partition_format_test +PREHOOK: Output: default@alter_partition_format_test@ds=2010 +POSTHOOK: query: alter table alter_partition_format_test partition(ds='2010') set fileformat rcfile +POSTHOOK: type: ALTERPARTITION_FILEFORMAT +POSTHOOK: Input: default@alter_partition_format_test +POSTHOOK: Input: default@alter_partition_format_test@ds=2010 +POSTHOOK: Output: default@alter_partition_format_test@ds=2010 +PREHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_partition_format_test +POSTHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_partition_format_test +# col_name data_type comment + +key int +value string + +# Partition Information +# col_name data_type comment + +ds string + +# Detailed Partition Information +Partition Value: [2010] +Database: default +Table: alter_partition_format_test +#### A masked pattern was here #### +Protect Mode: None +#### A masked pattern was here #### +Partition Parameters: + COLUMN_STATS_ACCURATE false +#### A masked pattern was here #### + numFiles 0 + numRows -1 + rawDataSize -1 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe +InputFormat: org.apache.hadoop.hive.ql.io.RCFileInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.RCFileOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: alter table alter_partition_format_test partition(ds='2010') set fileformat sequencefile +PREHOOK: type: ALTERPARTITION_FILEFORMAT +PREHOOK: Input: default@alter_partition_format_test +PREHOOK: Output: default@alter_partition_format_test@ds=2010 +POSTHOOK: query: alter table alter_partition_format_test partition(ds='2010') set fileformat sequencefile +POSTHOOK: type: ALTERPARTITION_FILEFORMAT +POSTHOOK: Input: default@alter_partition_format_test +POSTHOOK: Input: default@alter_partition_format_test@ds=2010 +POSTHOOK: Output: default@alter_partition_format_test@ds=2010 +PREHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@alter_partition_format_test +POSTHOOK: query: desc FORMATTED alter_partition_format_test partition(ds='2010') +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@alter_partition_format_test +# col_name data_type comment + +key int +value string + +# Partition Information +# col_name data_type comment + +ds string + +# Detailed Partition Information +Partition Value: [2010] +Database: default +Table: alter_partition_format_test +#### A masked pattern was here #### +Protect Mode: None +#### A masked pattern was here #### +Partition Parameters: + COLUMN_STATS_ACCURATE false +#### A masked pattern was here #### + numFiles 0 + numRows -1 + rawDataSize -1 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe +InputFormat: org.apache.hadoop.mapred.SequenceFileInputFormat +OutputFormat: org.apache.hadoop.mapred.SequenceFileOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 +PREHOOK: query: drop table alter_partition_format_test +PREHOOK: type: DROPTABLE +PREHOOK: Input: default@alter_partition_format_test +PREHOOK: Output: default@alter_partition_format_test +POSTHOOK: query: drop table alter_partition_format_test +POSTHOOK: type: DROPTABLE +POSTHOOK: Input: default@alter_partition_format_test +POSTHOOK: Output: default@alter_partition_format_test