hive - 在 Hive 中将列格式从字符串更新为日期
问题描述
我在 Hive 中有一个外部表
Current:
col1 - string
col2 - string
col3 - string
col4 - float
col5 - int
我想将 col3 的日期类型更改为 date
Expected:
col1 - string
col2 - string
col3 - date
col4 - float
col5 - int
我尝试了常规的 sql 命令但没有用
alter table table_name modify col3 date;
Error:
Error while compiling statement: FAILED: ParseException line 1:32 cannot recognize input near 'modify' 'col3' 'date' in alter table statement
在这里请求帮助。提前致谢。
解决方案
正确的命令是:
alter table table_name change col3 col3 date;
column change 命令只会修改 Hive 的元数据,不会修改数据。用户应确保表/分区的实际数据布局符合元数据定义。
请参阅此处的语法和手册:更改列名称/类型/位置/注释
推荐阅读
- amazon-web-services - 是否可以使用 AWS Lambda (HTTP API) 添加自定义标头
- reactjs - 收到错误为“postDetails”未定义 no-undef 我的状态变量
- sql-server - 由于插入触发器中的错误而未插入
- algorithm - Dijkstra:找到目的地时如何设置终止条件?
- ipython - iPython shell - 如何使用 $EDITOR 来编辑命令
- python - 在 Python 脚本中同时使用多处理和多线程来加快执行速度
- python - 用户警告:使用 0.22 版本时,尝试从 0.22.2.post1 版本中解开估计器 ExtraTreesClassifier
- recursion - 迭代定义深度的递归拆分
- javascript - 如何使用 Javascript D3 将单列 CSV 文件导入饼图?
- flutter - Flutter: Error: Error when reading '-': 系统找不到指定的文件