Impala - Get for all tables in database concentenated columns

白昼怎懂夜的黑 提交于 2019-12-24 10:39:40

问题


Lets say I have a database A with tables B1 and B2. B1 has columns C1 and C2

and B2 has columns D1, D2 and D3.

I am looking for an Impala query that yields the following desired output:

B1    | "C1+C2"

B2    | "D1+D2+D3"

where "D1+D2+D3" and "C1+C2" are concatenated strings.


回答1:


Do you want the concatenated columns in a new table? Or do you want to add the concatenated columns to your existing tables? Either way, you can use the code below in impala to concatenated columns:

SELECT 
CONCAT(C1,C2) AS concat_fields
, "B1" AS table_name
FROM B1
UNION
SELECT 
CONCAT(D1,D2,D3) AS concat_fields
, "B2" AS table_name
FROM B2


来源:https://stackoverflow.com/questions/49321946/impala-get-for-all-tables-in-database-concentenated-columns

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!