我在Hive中有两个表。
CREATE TABLE Target_table(
col_1 timestamp,
col_2 int,
col_3 int) CLUSTERED BY (col_1) INTO 50 BUCKETS STORED AS ORC
TBLPROPERTIES('transactional'='true')
CREATE TABLE Source_table(
col_1 timestamp,
col_2 int)
我正在尝试执行此查询
INSERT INTO Target_table (col_1, col_2)
SELECT col_1, col_2 FROM Source_table;
查询在直线中成功运行。
通过 Hortonworks ODBC 驱动程序执行时,相同的查询失败,并显示错误
ERROR [HY000] [Hortonworks][Hardy] (80) Syntax or semantic analysis error
thrown in server while executing query.
Error message from server: Error while compiling statement: FAILED:
SemanticException [Error 10044]: Line 1:18 Cannot insert into target table
because column number/types are different 'Targer': Table insclause-0 has 3
columns, but query has 2 columns.
看起来 Hive 完全忽略了插入子句中的列列表。
其他细节
Cluster: Azure HDInsight Cluster
Hortonworkds Data Platform: HDP-2.6.2.25
OS: Windows 10
Language: C#
任何帮助,不胜感激。
使用以下查询作为解决方法。
INSERT INTO Target_table(col_1, col_2, col_3) SELECT col_1, col_2,int(null) col_3 FROM Source_table;