【发布时间】: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