Array intersection operator
OriolLopezMassaguer opened this issue · comments
Hi!
I tried a query using "&&" postgresql array operator:
select count(*)
from clickhouse_test.pv_pm_reports3 ppr
where ppr.administration_routes && array['Oral']
where administration_routes is an array field accessed through the fdw but it fails:
ERROR: clickhouse_fdw: DB::Exception: Syntax error: failed at position 74 ('&'): && ['Oral'])). Unrecognized token: '&'
Are array operators avaliable through the fdw?
Hi.
No, I don't remember implementing them. But I always open to accept new pull requests :)
Can you give some guidance on how to implememt that?
Actually this case is more complex, clickhouse
doesn't have direct equivalent of this operation. What do you expect to see on clickhouse side?
We need the intersection && operator in posgresql to check if two arrays have elements in common:
array functions
I think this operator is equivalent to hasAny operator in clickhouse:
Am I wrong?
Assuming this is correct I implemented it in a fork:
I translate the following operators:
- @> as hasAll(op1,op2)
- <@ as hasAll(op2, op1)
- && as hasAny(op1, op2)
Missed these functions, could you add tests to check that they are working correctly and make a pull request?