表说明信息
hive> desc log23;
OK
col_name data_type comment
17/05/25 10:49:12 INFO mapred.FileInputFormat: Total input files to process : 1
host string from deserializer
remote_host string from deserializer
remote_logname string from deserializer
remote_user string from deserializer
request_time string from deserializer
request_method string from deserializer
request_url string from deserializer
first_line string from deserializer
http_status string from deserializer
bytes string from deserializer
referer string from deserializer
agent string from deserializer
Time taken: 0.049 seconds, Fetched: 12 row(s)
apache日志格式序列化
serializationLib:org.apache.hadoop.hive.contrib.serde2.RegexSerDe, parameters:{output.format.string=%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s %10$s %11$s %12$s, serialization.format=1, input.regex=([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) (-|\[[^\]]*\]) "(.[A-Z]*) (.*) (.*)" (-|[0-9]*) (-|[0-9]*) "(.*)" "(.*)"})
使用alterquery添加列
hive> alter table log23 add columns (code string);
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask.
Error: type expected at the position 0 of derived from deserializer:derived from deserializer:derived from deserializer:derived from deserializer:derived from deserializer:derived from deserializer:derived from deserializer:derived from deserializer:derived from deserializer:derived from deserializer:<derived from deserializer:derived from deserializer:string but>'<' is found.`
我得到一个像上面这样的错误失败了。如何添加列。。。?
4条答案
按热度按时间2hh7jdfx1#
我尝试了相同的方法,但我能够创建一个表并在末尾添加列:
创建表log23(主机字符串,远程主机字符串);altertablelog23添加列(代码字符串);
正在使用文本文件格式。请让我知道,如果您使用不同的文件格式,以便我尝试复制使用。
tgabmvqs2#
不幸的是,如果使用serde,就不能添加列。这是一个已知的问题:https://issues.apache.org/jira/browse/hive-17713
31moq8wy3#
“添加列”用于将新列添加到现有列的末尾,但在分区列之前。avro支持的表、hive0.14及更高版本也支持这一点。
替换列删除所有现有列并添加新的列集。只能对具有本机serde(dynamicserde、metadatatypedcolumnsetserde、lazysimpleserde和columnarserde)的表执行此操作。有关更多信息,请参阅hive serde。替换列也可用于删除列。例如,“alter table test_change replace columns(a int,b int);”将从test\u change的架构中删除列“c”。
wnavrhmk4#
我可以用直线很容易地完成这项工作-