-
Notifications
You must be signed in to change notification settings - Fork 473
compute: intra-ts thinning for monotonic topk #16813
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright Materialize, Inc. and contributors. All rights reserved. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the LICENSE file at the root of this repository. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0. | ||
|
||
# Test monotonicity analyses which derive from ENVELOPE NONE sources. | ||
# Note that these only test the implementation for monotonic sources, | ||
# they do not test that the analysis doesn't have false positives on | ||
# non-monotonic sources. | ||
|
||
$ set non-dbz-schema={ | ||
"type": "record", | ||
"name": "cpx", | ||
"fields": [ | ||
{"name": "a", "type": "long"}, | ||
{"name": "b", "type": "long"} | ||
] | ||
} | ||
|
||
$ kafka-create-topic topic=non-dbz-data | ||
|
||
$ kafka-ingest format=avro topic=non-dbz-data schema=${non-dbz-schema} timestamp=1 | ||
{"a": 1, "b": 1} | ||
{"a": 1, "b": 2} | ||
{"a": 1, "b": 3} | ||
{"a": 1, "b": 4} | ||
{"a": 1, "b": 5} | ||
{"a": 2, "b": 1000} | ||
{"a": 2, "b": 1001} | ||
{"a": 2, "b": 1002} | ||
{"a": 2, "b": 1003} | ||
{"a": 2, "b": 1004} | ||
|
||
> CREATE CONNECTION kafka_conn | ||
TO KAFKA (BROKER '${testdrive.kafka-addr}'); | ||
|
||
> CREATE SOURCE non_dbz_data | ||
FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-non-dbz-data-${testdrive.seed}') | ||
FORMAT AVRO USING SCHEMA '${non-dbz-schema}' | ||
ENVELOPE NONE | ||
|
||
# Create a monotonic topk plan that has both a limit and a group to test that thinning works as expected | ||
> SELECT * FROM (SELECT DISTINCT a FROM non_dbz_data) grp, LATERAL (SELECT b FROM non_dbz_data WHERE a = grp.a ORDER BY b LIMIT 2); | ||
a b | ||
--------- | ||
1 1 | ||
1 2 | ||
2 1000 | ||
2 1001 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a lot like a
ChangeBatch
; is there a specific reason it isn't that (plus thelimit
and a method to prune based on the limit).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not an accident, I did copy the methods from
ChangeBatch
. The thing I couldn't do withChangeBatch
is remove the records that I don't need anymore every time compaction happens. I couldn't think of an API that would make sense to add toChangeBatch
to allow for that customization but maybe you have an idea?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frankmcsherry this is the only outstanding comment. I pulled in
differential_dataflow::consolidation
to do the consolidation but that locks us in with theOrd
trait. I can put the manual consolidation back here and sort based on a sharedVec<ColumnOrder>
. What do you prefer?The
Top1
plan suffers from the same problem if that makes you feel any better 😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not! :D
We should either have an issue open, or a
// TODO
, or a fix. This seems like a fine place to eventually do the work for both cases. You needn't do it here right now, but we should open up an issue if we leave it undone!