hive - Hive - 无法识别选择子句中的输入“插入”
问题描述
假设我已经创建了 table3,并尝试使用以下代码将数据插入其中
WITH table1
AS
(SELECT 1 AS key, 'One' AS value),
table2
AS
(SELECT 1 AS key, 'I' AS value)
INSERT TABLE table3
SELECT t1.key, t1.value, t2.value
FROM table1 t1
JOIN table2 t2
ON (t1.key = t2.key)
但是,我收到一个错误,因为无法识别 select 子句中的输入“插入”。如果我只是删除插入语句,那么查询运行得很好。
这是语法问题吗?或者我不能使用 with 子句插入?
解决方案
根据您的需要使用 INTO 或 OVERWRITE:
INSERT INTO TABLE table3 --this will append data, keeping the existing data intact
或者
INSERT OVERWRITE TABLE table3 --will overwrite any existing data
阅读手册:从查询中将数据插入 Hive 表
推荐阅读
- javascript - 如何从名称数组中返回所有带有第二个字母“h”的名称?
- javascript - 如何点击没有id的下拉列表
- mongodb - 将有序数组重塑为表格
- android - setColor 小图标通知android
- java - java.lang.UnsupportedOperationException:Robolectric 不支持 API 级别 1
- rust - Rust 如何理解仅使用 FromIterator::from_iter 调用 from_iter 的适当实现?
- angular - 内部匿名函数中的 Angular 6 范围字段
- angularjs - 如何将令牌发送到 API?在打字稿中
- css - Bem 名称太长 - 最佳实践
- python - 生成了许多 CSV 文件(工作簿)。我希望它们作为单个 CSV 文件(在单个工作表中的一个工作簿下)。(在网络爬行中)