clickhouse_fdw icon indicating copy to clipboard operation
clickhouse_fdw copied to clipboard

Array intersection operator

Open OriolLopezMassaguer opened this issue 4 years ago • 6 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?

OriolLopezMassaguer avatar Jul 13 '21 09:07 OriolLopezMassaguer

Hi. No, I don't remember implementing them. But I always open to accept new pull requests :)

ildus avatar Jul 13 '21 09:07 ildus

Can you give some guidance on how to implememt that?

OriolLopezMassaguer avatar Jul 13 '21 12:07 OriolLopezMassaguer

Actually this case is more complex, clickhouse doesn't have direct equivalent of this operation. What do you expect to see on clickhouse side?

ildus avatar Jul 16 '21 16:07 ildus

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:

clickhouse array functions

Am I wrong?

Assuming this is correct I implemented it in a fork:

fdw fork

I translate the following operators:

  • @> as hasAll(op1,op2)
  • <@ as hasAll(op2, op1)
  • && as hasAny(op1, op2)

OriolLopezMassaguer avatar Jul 18 '21 09:07 OriolLopezMassaguer

Missed these functions, could you add tests to check that they are working correctly and make a pull request?

ildus avatar Jul 18 '21 17:07 ildus

I will do

El dg., 18 de jul. 2021, 19:16, Ildus Kurbangaliev @.***> va escriure:

Missed these functions, could you add tests that they are working correctly and make a pull request?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/adjust/clickhouse_fdw/issues/73#issuecomment-882089574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJEDVCRFGL4QMPDC75ZFSLTYMD7TANCNFSM5AIUWUWQ .

OriolLopezMassaguer avatar Jul 19 '21 07:07 OriolLopezMassaguer