简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM