Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array intersection operator #73

Open
OriolLopezMassaguer opened this issue Jul 13, 2021 · 6 comments
Open

Array intersection operator #73

OriolLopezMassaguer opened this issue Jul 13, 2021 · 6 comments

Comments

@OriolLopezMassaguer
Copy link

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?

@ildus
Copy link
Owner

ildus commented Jul 13, 2021

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

@OriolLopezMassaguer
Copy link
Author

OriolLopezMassaguer commented Jul 13, 2021

Can you give some guidance on how to implememt that?

@ildus
Copy link
Owner

ildus commented Jul 16, 2021

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

@OriolLopezMassaguer
Copy link
Author

OriolLopezMassaguer commented Jul 18, 2021

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)

@ildus
Copy link
Owner

ildus commented Jul 18, 2021

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

@OriolLopezMassaguer
Copy link
Author

OriolLopezMassaguer commented Jul 19, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants