Home > Blockchain >  How to insert from one hive table to another using select for one column
How to insert from one hive table to another using select for one column

Time:11-11

I am trying to insert from one table to another using:

Insert into table energyx 
Select log_id, 
house_id, 
condate, 
conhour, 
energy_reading, 
flag, 
(select substring(condate, 0, 7)) 
from energy1;

However, I get the error: unsupported subquery expression

CodePudding user response:

you don’t need the second select, all you need is this:

Insert into table energyx 
Select log_id, 
house_id, 
condate, 
conhour, 
energy_reading, 
flag, 
substring(condate, 0, 7)
from energy1;

However, it is generally not a good design to duplicate data. You already have the value of condate in your table so you shouldn’t also be adding a substring of that value - as that substring can be created whenever the table is queried

  • Related