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

adapter/storage: Cast MySQL bit columns to uint8, add convience functions #31097

Merged
merged 8 commits into from
Jan 21, 2025

Conversation

ParkMyCar
Copy link
Member

@ParkMyCar ParkMyCar commented Jan 17, 2025

This PR changes the MySQL source to support ingesting the bit type as uint8. It also adds two new Postgres functions, bit_count(bytea) and get_bit(bytea, int32) to making working with byte strings easier.

Motivation

Progress towards: https://github.com/MaterializeInc/database-issues/issues/8891

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

@ParkMyCar ParkMyCar requested review from a team as code owners January 17, 2025 19:29
@ParkMyCar ParkMyCar requested a review from jkosh44 January 17, 2025 19:29
Copy link
Contributor

@jkosh44 jkosh44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I think we should add docs for the new functions.

@@ -24,7 +24,6 @@ rust_library(
compile_data = [],
crate_features = ["default"],
data = [],
disable_pipelining = True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to include this in this PR? It seems a bit unrelated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't was rebased on the wrong branch by accident, removed!

.get(byte_index)
.map(|b| (*b >> bit_index) & 1)
.ok_or(err)?;
Ok(Datum::from(i32::from(i)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding correctly, the following might be useful: assert!(i == 0 || i == 1)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

@ParkMyCar
Copy link
Member Author

LGTM, but I think we should add docs for the new functions.

Good idea, I'll add them in a separate PR though so we can merge them when v0.131 goes out

@ParkMyCar ParkMyCar enabled auto-merge (squash) January 17, 2025 19:58
@ParkMyCar ParkMyCar disabled auto-merge January 17, 2025 20:04
@ParkMyCar ParkMyCar changed the title adapter/storage: Cast MySQL bit columns to bytea, add convience functions adapter/storage: Cast MySQL bit columns to uint8, add convience functions Jan 17, 2025
Copy link
Contributor

@def- def- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding tests!

Edit: I added platform checks scenario, green nightly run with it: https://buildkite.com/materialize/nightly/builds/10923

@def- def- requested a review from a team as a code owner January 21, 2025 09:23
@ParkMyCar ParkMyCar merged commit 925f577 into MaterializeInc:main Jan 21, 2025
112 checks passed
ggevay pushed a commit that referenced this pull request Jan 21, 2025
…unctions (#31097)

This PR changes the MySQL source to support ingesting the `bit` type as
`uint8`. It also adds two new Postgres functions, `bit_count(bytea)` and
`get_bit(bytea, int32)` to making working with byte strings easier.

### Motivation

Progress towards:
MaterializeInc/database-issues#8891

### Checklist

- [x] This PR has adequate test coverage / QA involvement has been duly
considered. ([trigger-ci for additional test/nightly
runs](https://trigger-ci.dev.materialize.com/))
- [x] This PR has an associated up-to-date [design
doc](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/design/README.md),
is a design doc
([template](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/design/00000000_template.md)),
or is sufficiently small to not require a design.
  <!-- Reference the design in the description. -->
- [x] If this PR evolves [an existing `$T ⇔ Proto$T`
mapping](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/command-and-response-binary-encoding.md)
(possibly in a backwards-incompatible way), then it is tagged with a
`T-proto` label.
- [x] If this PR will require changes to cloud orchestration or tests,
there is a companion cloud PR to account for those changes that is
tagged with the release-blocker label
([example](MaterializeInc/cloud#5021)).
<!-- Ask in #team-cloud on Slack if you need help preparing the cloud
PR. -->
- [x] If this PR includes major [user-facing behavior
changes](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/guide-changes.md#what-changes-require-a-release-note),
I have pinged the relevant PM to schedule a changelog post.

---------

Co-authored-by: Dennis Felsing <[email protected]>
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.

3 participants