在 hive 的列中查找值

发布于 2025-01-15 06:37:39 字数 287 浏览 1 评论 0原文

我在hive中有一个要求,在列中查找一个值,数据是“;”单列中的分隔值。如果我需要的值存在,则结果应该为 TRUE,否则为 FALSE。

例如:单列中的数据为

Row1:保险;金融;电信

Row2:保险、零售

Row3:金融、电信、内部

像这样,我在一列中有不同的值。 我想知道该列是否包含“财务”。如果存在,则输出结果应为 TRUE,否则为 FALSE

: 第 1 行:正确

第 2 行:错误

第 3 行:正确

请帮忙。提前致谢。

I have a requirement in hive to find a value in a column, data is ";" separated values in single column. if my required value present it should result TRUE else FALSE.

Ex: data in a single column is

Row1: insurance;finance;telecom

Row2: insurance, retail

Row3: finance, telecom, internal

Like this I have different values in a column.
I wanted to find if the column contains "finance" or not. If present it should result TRUE else FALSE

output:
Row1: TRUE

Row2: FALSE

Row3: TRUE

Please help. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

金橙橙 2025-01-22 06:37:39

如果您正在寻找单个硬编码值,可以使用 like 运算符。
where col like '%finance%'.

但是如果你希望它是来自另一个表的变量 qnd,你可以像这样使用它

Select...
From table1 t1,
join table2 t2 on t1.col like concat('%', t2.colpattern, '%')

If you are looking for single hardcode value, you can use like operator.
where col like '%finance%'.

But if you want it to be a variable qnd coming from another table you can use it like this

Select...
From table1 t1,
join table2 t2 on t1.col like concat('%', t2.colpattern, '%')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文