1

Hi I am using SnappyData and trying to update Table_A with rows from Table_B:

Table_A(key1, key2, val, primary key(key1, key2)) -- cumulative results
Table_B(key1, key2, val, primary key(key1, key2)) -- new rows - updates

Since the Table_B would contain (key1, key2) values that already exist in Table_A, and should replace those in Table_A. So I am using the "PUT INTO" instead of "INSERT INTO" statements to update the cumulative results stored in Table_A

And my PUT INTO statement looks like this:

PUT INTO Table_A
SELECT * from Table_B

But the rows in Table_B does not show up in Table_A.

However if I insert values directly:

PUT INTO Table_A
VALUES (1, 1, 1)

the row (1, 1, 1) does show up in Table_A. And if I use INSERT:

INSERT INTO Table_A
SELECT * from Table_B

The rows from Table_B show up in Table_A, until there is a dup key error and my program exits.

I tried single column primary key (i.e. key1) and still no luck.

So what am I doing wrong here? Or is the "PUT INTO" not working or is there a delay in "PUT INTO" statements?

UPDATE:

I was using SnappyData local mode, and I just tried cluster mode and encountered some error here (strange it does not throw the error in local mode, instead it's just not working silently.)

Community
  • 1
  • 1
user3230153
  • 123
  • 3
  • 11
  • Will get this answered for you ASAP – plamb Apr 13 '17 at 18:58
  • Thanks for the comment, please see my updated message and the error I encountered here in cluster mode: http://stackoverflow.com/questions/43402885/snappydata-snappy-sql-put-into-cause-errorspark-sql-execution-id-is-already-set – user3230153 Apr 13 '17 at 22:55
  • You just need to provide table_a schema in the put into statement - So it should be : snappy> put into table_a (key1, val) select * from table_b; – Yogesh Mahajan Apr 14 '17 at 00:29
  • Thanks a lot it works now! It would be great if you post your answer and i'll upvote yours :) Also it would be great if you guys can update the document: http://rowstore.docs.snappydata.io/docs/reference/language_ref/put-into.html it's kind of frustrating following the document while it doesn't work. – user3230153 Apr 14 '17 at 02:00

2 Answers2

2

You just need to provide table_a schema in the put into statement - So it should be : snappy> put into table_a (key1, val) select * from table_b;

Yogesh Mahajan
  • 241
  • 1
  • 4
1

Yes, we have added a doc ticket to track this and docs should be updated accordingly. Thanks.

Yogesh Mahajan
  • 241
  • 1
  • 4