【问题标题】:INSERT INTO in BigSQL exception在 BigSQL 异常中插入 INTO
【发布时间】:2015-04-20 07:55:10
【问题描述】:

我正在 Big SQL 中创建一个表(例如 table1),并将数据从 HDFS 加载到 table1。现在从这个table1,我需要根据某些条件将数据加载到另一个表,比如table2,并且每天将更多数据附加到这个table2。每日新数据将被加载到table1,相应的新数据也应该进入table2

我尝试了以下方法

第一

insert append into table table2 as select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;

遇到的 SQL 异常:[状态:42601][代码:-104]:解析错误:
insert append into table table2 as select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;

第二

insert into table table2 as select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;

遇到的 SQL 异常: [状态:58004][代码:15]:BIGSQL-GEN-0010 发现内部错误:
'执行查询'insert into table table2 as select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;': expected keyword values'失败。

第三

create table if not exists table2(URL_NAME,TODAY_DATE,COUNT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' as select uri,localtimestamp,count(*) from table1 where request_timestamp=localtimestamp group by uri order by uri LIMIT 100;

在这种情况下,每天都会创建新表,而我希望保留旧数据并添加新数据。

第四个

创建表table2

CREATE EXTERNAL TABLE table2 (URL_NAME VARCHAR(500),DATE varchar(50),COUNT INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
0 rows affected (total: 0.22s)

insert overwrite table table2 select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;

遇到的 SQL 异常:
[状态:42601][代码:-104]:解析错误:

<query>insert overwrite table table2 select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;</query> Expecting token <into> after token <insert>

第五

Load from sql query 'select uri, request_timestamp,1 from table1 where $conditions' split column uri into table table2;

遇到的 SQL 异常:
[状态:58004][代码:15]:BIGSQL-GEN-0010 发现内部错误:

'未能执行查询'Load from sql query 'select uri, request_timestamp,1 from table1 where $conditions' split column uri into table table2':解析错误:关键字 hbase 或 hive 预期'。

如果我使用关键字 hive 运行

遇到的 SQL 异常:
[状态:58004][代码:15]:BIGSQL-GEN-0010 发现内部错误:

'执行查询失败'Load hive from sql query 'select uri, request_timestamp,1 from table1 where $conditions' split column uri into table table2'`: 原始表达式结束于 (line: 1, column: 143):由于 Hive MetaStore 中的错误,语句失败。 Hadoop 日志条目标识符:“[4d4e59269]”: com.ibm.biginsights.catalog.translator.hive.HiveExceptionTranslator$HiveNestedException: FAILED: ParseException line 1:5 mismatched input 'from' expect DATA near 'load' in load statement

知道如何使用INSERT INTO 语句或如何使用 IBM BigSQL(版本 1)将数据从表加载到另一个

更新


我也尝试了LOAD,但遇到了异常

LOAD FROM SQL QUERY 'select t1.uri, t1.request_timestamp,t1.cell_lac from sample.web3 t1 where $conditions'  split column t1.uri into table sample.u2_table;

遇到的 SQL 异常: [状态:58004][代码:15]:BIGSQL-GEN-0010 发现内部错误:'无法执行查询'LOAD FROM SQL QUERY 'select t1.uri, t1. request_timestamp,t1.cell_lac from sample.web3 t1 where $conditions' split column t1.uri into table sample.u2_table':解析错误:关键字 hbase 或 hive 预期'。

LOAD FROM SQL QUERY 'select t1.uri, t1.request_timestamp,t1.cell_lac from sample.web3 t1 where $conditions' split column t1.uri into hive table sample.u2_table;

遇到的 SQL 异常: [状态:58004][代码:15]:BIGSQL-GEN-0010 发现内部错误:'无法执行查询'LOAD FROM SQL QUERY 'select t1.uri, t1.request_timestamp,t1.cell_lac from sample.web3 t1 where $conditions' split column t1.uri into hive table sample.u2_table':解析错误:关键字 hbase 或 hive 预期'。

LOAD FROM TABLE sample.web3 COLUMNS (uri,request_timestamp, cell_lac) INTO hive TABLE sample.u2_table APPEND WITH LOAD PROPERTIES (num.map.tasks = 1);

遇到的 SQL 异常: [状态:58004][代码:15]:BIGSQL-GEN-0010 发现内部错误:'无法执行查询'LOAD FROM TABLE sample.web3 COLUMNS (uri,request_timestamp, cell_lac) INTO hive TABLE sample.u2_table APPEND WITH LOAD PROPERTIES (num.map.tasks = 1)':解析错误:关键字 hbase 或 hive 预期'。

【问题讨论】:

    标签: biginsights bigsql


    【解决方案1】:

    我认为,你不能以那种方式使用 INSERT

    INSERT 语句将单行插入到 IBM® Big SQL HBase 表中。

    LOAD 语句将数据加载到表中。您可以从远程数据源加载到 HBase 或 Hive。 您可以从您的集群或本地文件加载到 HBase 或 Hive

    当你想像使用HIVE DATA一样使用本地文件时,首先你需要使用EXPORT TO

    您的第五个解决方案是您想要的并且应该改进:

    LOAD FROM SQL QUERY 'select uri, request_timestamp,1 from table1 where $conditions' split column uri into table table2;
    

    select 子句中的列必须与目标表定义中列的名称和类型匹配。
    否则,您必须指定 column.names 属性以指定到目标列的映射。

    • 1 没有名字
    • 为您的table1 使用别名,如下所示:... 'select t1.uri, ... from table1 t1 ... ' SPLIT COLUMN t1.uri ...
    • 您可以通过另一种方式使用LOAD FROM TABLE table1 COLUMNS (uri,request_timestamp, ...) INTO hbase TABLE table2 APPEND WITH LOAD PROPERTIES (num.map.tasks = 1)

    【讨论】:

    • 将在此处尝试并更新。截至目前,biginsight 服务器已关闭 :( 感谢您的回复
    • 已尝试您指定的建议,但出现异常。我已经更新了答案以包含它
    猜你喜欢
    • 1970-01-01
    • 2011-12-07
    • 1970-01-01
    • 1970-01-01
    • 2019-05-06
    • 2012-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多