How can I solve this hive sql problem? (Like join in Hive)

Viewed 28

I know Hive only provide equi join. For example, below sql statement. select * from A join B on A.c1 = B.c2 where 1=1;

But I want to execute Like join Query in Hive. For example, below sql statement. select * from A join B on A.c1 like B.c2 where 1=1;

Please let me know if you know the solution in Hive.

1 Answers

How about -

ON A.c1 LIKE concat('%',B.c2,'%')

concat will concatenate % to the c2 data so like operator will work properly. whole sql will be like -

select * from A join B on A.c1 LIKE concat('%',B.c2,'%') where 1=1;

version - hive 2.1.1

Related