Impala-获取数据库集中列中的所有表 [英] Impala - Get for all tables in database concentenated columns

查看:1625
本文介绍了Impala-获取数据库集中列中的所有表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有一个数据库A,其中包含表B1和B2. B1有C1和C2列

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

并且B2具有D1,D2和D3列.

and B2 has columns D1, D2 and D3.

我正在寻找一个Impala查询,该查询会产生以下期望的输出:

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

B1    | "C1+C2"

B2    | "D1+D2+D3"

其中"D1 + D2 + D3"和"C1 + C2"是串联字符串.

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

推荐答案

是否要在新表中并置列?还是要将串联的列添加到现有表中?无论哪种方式,您都可以在impala中使用以下代码来连接列:

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

这篇关于Impala-获取数据库集中列中的所有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆