Select insert support


#1

Hello,

Is there any way I can insert data from select statement in a fashion of insert into table1 from (select * table2).
I’m aware that there is “create table table1 from (select …)” however I need to insert data in the same table from multiple tables. Reading docs I see that there is COPY statement but as far as I understand it only works for the files and it seems silly to save my pandas DF to file first and then push it to mapd (useless disk overhead).


#2

As a workaround you can use streminsert Command. Write on a pipe with a copy Command while Reading from the same pipe with streminsert.


#3

Hi @antonio.dolic,

Thanks for your interest in MapD.

Insert into select is on our roadmap, however in the interim you can use the workaround that @aznable suggested.

We will keep you posted as things progress on this front.

Regards


#4

can you please show a snippet how to use streminsert Command?


#5

Hi @romka,

Here is an example command line that worked for me. Here I am taking the input from a SELECT from one table and piping to StreamInsert into another table. Important to note that as the output from mapdql comes with the fields separated by “|”, we need to specify that as the delimiter.

echo ‘select * from foobar2;’ | bin/mapdql -u mapd -p HyperInteractive --db mapd | tail -n +2 | grep -v “User mapd” | SampleCode/StreamInsert foobar1 -u mapd -p HyperInteractive --port 9091 --delim | --null NULL --database mapd

Regards,
Veda