如何在组内订购。在hive中额外使用concate_ws和collect_set

时间:2017-10-31 22:35:38

标签: sql hadoop hive

我有这种格式的数据 出于安全原因,我将****放在短语列中。这基本上是党派的一句话。 Data

这是1个特定ID的有序对话。

我想达到这个结果: 再次***而不是句子。 result

我用来实现此目的的查询:

select tmp.interaction_id,collect_set(tmp.final) from
(select interaction_id,concat_ws(':--  ',party,phrase) as 
final,start_offset,end_offset  from aads_piim.A608232_Myvoice_wt_transcript
 where interaction_id=26951370
order by start_offset,end_offset) as tmp
group by tmp.interaction_id;

我可以这样做,因为我只对1个ID进行排序。然后正确地订购对话。像代理商和客户序列。 我有大约400K这样的记录。我想为他们做类似的事情。 我正在使用的查询是:

create table aads_piim.a608232_myvoice_transcript_combined as
select tmp.interaction_id,collect_set(tmp.final) as final_trans from
(select interaction_id,concat_ws(':--  ',party,phrase) as 
final,start_offset,end_offset  from aads_piim.A608232_Myvoice_wt_transcript 
order by start_offset,end_offset) as tmp
group by tmp.interaction_id;

但是在这里排序时考虑所有ID。 我的问题是如何在IDS内进行排序。表示在我的情况下,如何按ID和按该特定ID的偏移列进行排序。

1 个答案:

答案 0 :(得分:0)

首先按interaction_id排序,然后按偏移量排序。

<!-- update these with your appid and one of your appsecret keys-->
<add key="MicrosoftAppID" value="XXXXXXXXXXXXXX" />
<add key="MicrosoftAppPassword" value="YYYYYYYYYY" />
<!--Azure Credentials (V1 Authentication Mode) -->
<add key="ActiveDirectory.Mode" value="v1" />
<add key="ActiveDirectory.ResourceId" value="https://graph.windows.net/" />
<add key="ActiveDirectory.EndpointUrl" value="https://login.microsoftonline.com" />
<add key="ActiveDirectory.Tenant" value="ZZZZZZZ" />
<add key="ActiveDirectory.ClientId" value="aaa" />
<add key="ActiveDirectory.ClientSecret" value="bbb" />
<add key="ActiveDirectory.RedirectUrl" value="http://localhost:25601/api/OAuthCallback" />