-
Notifications
You must be signed in to change notification settings - Fork 503
arrow-util: canonicalize ranges decoded from Parquet #36499
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
Open
DAlperin
wants to merge
1
commit into
main
Choose a base branch
from
claude/fix-parquet-range-canonicalization-LghhN
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+193
−25
Open
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
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,52 @@ | ||
| # 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. | ||
|
|
||
| # Regression test for database-issues#11330: COPY FROM PARQUET must canonicalize | ||
| # range values. External engines (here, DuckDB) author the Parquet file with | ||
| # non-canonical bounds for discrete ranges (e.g. `[1,10]` and `(5,15)` for | ||
| # int4range). MZ must rewrite these into its canonical half-open form on | ||
| # ingest, otherwise the resulting rows do not compare or hash equal to ranges | ||
| # constructed inside MZ. | ||
|
|
||
| > CREATE SECRET access_key_secret AS '${arg.s3-access-key}' | ||
|
|
||
| > CREATE CONNECTION aws_conn TO AWS ( | ||
| ACCESS KEY ID = 'tduser', | ||
| SECRET ACCESS KEY = SECRET access_key_secret, | ||
| ENDPOINT = 'http://${arg.aws-endpoint}', | ||
| REGION = 'us-east-1' | ||
| ); | ||
|
|
||
| $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr} | ||
| ALTER SYSTEM SET enable_copy_from_remote = true; | ||
|
|
||
| # Author the Parquet file directly in minio with DuckDB, so the bytes are not | ||
| # something MZ's own sink produced. The struct shape mirrors MZ's range | ||
| # encoding (lower/upper/lower_inclusive/upper_inclusive/empty). | ||
| $ duckdb-execute name=ranges | ||
| CREATE SECRET s3_secret (TYPE S3, KEY_ID 'tduser', SECRET '${arg.s3-access-key}', ENDPOINT '${arg.aws-endpoint}', URL_STYLE 'path', USE_SSL false, REGION 'minio'); | ||
| COPY (SELECT * FROM (VALUES (1, {'lower': 1::INTEGER, 'upper': 10::INTEGER, 'lower_inclusive': true, 'upper_inclusive': true, 'empty': false}), (2, {'lower': 5, 'upper': 15, 'lower_inclusive': false, 'upper_inclusive': false, 'empty': false})) t(id, r) ORDER BY id) TO 's3://test-bucket/noncanon_ranges/data.parquet' (FORMAT PARQUET); | ||
|
|
||
| > CREATE TABLE ranges(id int, r int4range); | ||
|
|
||
| > COPY INTO ranges FROM 's3://test-bucket/noncanon_ranges' (FORMAT PARQUET, AWS CONNECTION = aws_conn); | ||
|
|
||
| # DuckDB's `[1,10]` and `(5,15)` must arrive as MZ's canonical `[1,11)` and | ||
| # `[6,15)`. | ||
| > SELECT id, r::text FROM ranges ORDER BY id; | ||
| 1 [1,11) | ||
| 2 [6,15) | ||
|
|
||
| # Once canonicalized, the rows must compare equal to logically-identical | ||
| # values constructed inside MZ. | ||
| > SELECT r = '[1,10]'::int4range FROM ranges WHERE id = 1; | ||
| true | ||
|
|
||
| > SELECT r = '(5,15)'::int4range FROM ranges WHERE id = 2; | ||
| true |
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.
Many workflows in test/iceberg do just this, we could put them all in a workflow_cdc instead that iterates over the files? But more of a test cleanup, not that important for this PR itself.