现象
FAILED: ParseException line 1:48 cannot recognize input near 'ADD' 'COLUMN' 'compete_company_id' in alter table statement
23/11/14 17:59:27 ERROR org.apache.hadoop.hive.ql.Driver: FAILED: ParseException line 1:48 cannot recognize input near 'ADD' 'COLUMN' 'compete_company_id' in alter table statement
org.apache.hadoop.hive.ql.parse.ParseException: line 1:48 cannot recognize input near 'ADD' 'COLUMN' 'compete_company_id' in alter table statement
原因一
comment后面的文字描述应该用单引号括起来,不能用双引号。
改成单引号就对了
原因二
如果语句是
ALTER TABLE table_name ADD COLUMN table_name type COMMENT '竞品公司id';
那么这个语句是错的
要么改成
ALTER TABLE table_name ADD COLUMNS (table_name type COMMENT '竞品公司id');
要么就写成
ALTER TABLE table_name ADD COLUMN table_name type;