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

maxIntersections: add sorting by weight #2657

Conversation

furmur
Copy link
Contributor

@furmur furmur commented Jul 16, 2018

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

add sorting by weight to fix dependence on the order of intervals when end of the one interval matches with start of the another interval

wrong behavior example:

CREATE TABLE test1(start Integer, end Integer) engine = Memory;
CREATE TABLE test2(start Integer, end Integer) engine = Memory;
INSERT INTO test1(start,end) VALUES (1,3),(3,5);
INSERT INTO test2(start,end) VALUES (3,5),(1,3);
void :) SELECT maxIntersections(start,end) from test1;

SELECT maxIntersections(start, end)
FROM test 

┌─maxIntersections(start, end)─┐
│                            1 │
└──────────────────────────────┘

1 rows in set. Elapsed: 0.002 sec. 

void :) SELECT maxIntersections(start,end) from test2;

SELECT maxIntersections(start, end)
FROM test2 

┌─maxIntersections(start, end)─┐
│                            2 │
└──────────────────────────────┘

1 rows in set. Elapsed: 0.003 sec.

expected to receive the same value 1 for both cases

patch fixes function by placing points with weight -1 before points with weight 1 and the same position

@alexey-milovidov
Copy link
Member

Missing test.

alexey-milovidov added a commit that referenced this pull request Jul 16, 2018
@alexey-milovidov alexey-milovidov merged commit d1eac37 into ClickHouse:master Jul 16, 2018
@furmur
Copy link
Contributor Author

furmur commented Jul 16, 2018

thank you ) i had to check default sort behavior first

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

Successfully merging this pull request may close these issues.

2 participants