I am creating a table (say table1
) in Big SQL, and loading the data from HDFS into table1
. Now from this table1
, I need to to load data to another table say table2
, based on certain conditions and on daily basis append more data into this table2
. Daily new data will be loaded into table1
and correspondingly new data should come into table2
as well.
I have tried the following ways
First
insert append into table table2 as select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;
SQL Exception(s) Encountered: [State: 42601][Code: -104]: Error parsing:
insert append into table table2 as select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;
Second
insert into table table2 as select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;
SQL Exception(s) Encountered: [State: 58004][Code: 15]: BIGSQL-GEN-0010 Found an internal error:
'Failed to execute query 'insert into table table2 as select uri,localtimestamp,count(*) from table1 group by uri order by uri LIMIT 100;': expected keyword values
'.
Third
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;
In this case, everyday, new table will be created, while I want the older data to be retained and new data to be added.
Fourth
Create table 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 Exception(s) Encountered:
[State: 42601][Code: -104]: Error parsing:
<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>
Fifth
Load from sql query 'select uri, request_timestamp,1 from table1 where $conditions' split column uri into table table2;
SQL Exception(s) Encountered:
[State: 58004][Code: 15]: BIGSQL-GEN-0010 Found an internal error:'Failed to execute query '
Load from sql query 'select uri, request_timestamp,1 from table1 where $conditions' split column uri into table table2
': parse error: keyword hbase or hive expected'.
And if I run with keywords hive
SQL Exception(s) Encountered:
[State: 58004][Code: 15]: BIGSQL-GEN-0010 Found an internal error:'Failed to execute query '
Load hive from sql query 'select uri, request_timestamp,1 from table1 where $conditions' split column uri into table table2
'`: originating expression ends at (line: 1, column: 143): The statement failed because of an error in the Hive MetaStore. Hadoop log entry identifier: "[4d4e59269]"": com.ibm.biginsights.catalog.translator.hive.HiveExceptionTranslator$HiveNestedException: FAILED: ParseException line 1:5 mismatched input 'from' expecting DATA near 'load' in load statement
Any idea how to use INSERT INTO
statement or how to load data from table to another using IBM BigSQL (version 1)
Update
I tried with LOAD
as well but getting excpetions
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 Exception(s) Encountered: [State: 58004][Code: 15]: BIGSQL-GEN-0010 Found an internal error: 'Failed to execute query
'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'
: parse error: keyword hbase or hive expected'.
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 Exception(s) Encountered: [State: 58004][Code: 15]: BIGSQL-GEN-0010 Found an internal error: 'Failed to execute query
'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'
: parse error: keyword hbase or hive expected'.
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 Exception(s) Encountered: [State: 58004][Code: 15]: BIGSQL-GEN-0010 Found an internal error: 'Failed to execute query
'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)'
: parse error: keyword hbase or hive expected'.