-
Notifications
You must be signed in to change notification settings - Fork 473
[persist] PARTITION BY for Persist-backed collections #30355
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
Show all changes
6 commits
Select commit
Hold shift + click to select a range
369d9da
PARTITION BY for materialized views
bkirwi 182f4a1
preserves_order function for persist encoding
bkirwi 2423914
Check the partition_by clause for MVs during planning
bkirwi bd14f45
Add a feature flag for PARTITION BY
bkirwi b8665c4
Testdrive test for PARTITION BY checks
bkirwi 1725762
Add property testing for preserves_order
bkirwi 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
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
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
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,35 @@ | ||
# 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. | ||
|
||
# Tests for the new PARTITION BY syntax for persisted collections. | ||
|
||
# First, check that the flag is disabled by default. | ||
|
||
! CREATE MATERIALIZED VIEW integers (n) WITH (PARTITION BY (n)) AS VALUES (3), (2), (1); | ||
contains:PARTITION BY | ||
|
||
$ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr} | ||
ALTER SYSTEM SET enable_collection_partition_by = true | ||
|
||
> CREATE MATERIALIZED VIEW integers (n) WITH (PARTITION BY (n)) AS VALUES (3), (2), (1); | ||
|
||
> CREATE MATERIALIZED VIEW integers_strings (n, m) WITH (PARTITION BY (n, m)) | ||
AS VALUES (3, 'three'), (2, 'two'), (1, 'one'); | ||
|
||
! CREATE MATERIALIZED VIEW out_of_order (n, m) WITH (PARTITION BY (m, n)) | ||
AS VALUES (3, 'three'), (2, 'two'), (1, 'one'); | ||
contains:PARTITION BY columns should be a prefix | ||
|
||
! CREATE MATERIALIZED VIEW out_of_order (n, m) WITH (PARTITION BY (m)) | ||
AS VALUES (3, 'three'), (2, 'two'), (1, 'one'); | ||
contains:PARTITION BY columns should be a prefix | ||
|
||
! CREATE MATERIALIZED VIEW unsupported_type (n, m) WITH (PARTITION BY (n, m)) | ||
AS VALUES (3, '[3]'::json), (2, '[2]'::json), (1, '[1]'::json); | ||
contains:PARTITION BY column m has unsupported type |
Oops, something went wrong.
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.
Is there anyway to add tests for this to make sure it's correct? Also when adding a new type, how do we know whether to return
true
orfalse
?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.
Good callout! I've added some lines to our property test that checks the sorted column is also sorted according to the schema when preserves_order is true.
I think the idea is that whoever is designing a new encoding for a type should make a reasonable effort to ensure this property is true... so they should be in a good position to know whether they managed it or not. (And hopefully now the test will keep them honest!)