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

repr: add Datum::Range + misc. #16296

Merged
merged 2 commits into from
Dec 5, 2022
Merged

Conversation

sploiselle
Copy link
Contributor

We're looking to support range types, and this is the first step.

Once this lands, we'll be able to perform the migration of the current reclocking data to the new, more Timely-friendly format.

After that we'll extend support for the range types (e.g. making them SELECTable).

Motivation

This PR adds a known-desirable feature. Design doc

Checklist

@sploiselle sploiselle requested review from benesch and a team November 27, 2022 20:48
src/repr/src/scalar.rs Outdated Show resolved Hide resolved
src/repr/src/row/encoding.rs Outdated Show resolved Hide resolved
src/repr/src/row.proto Outdated Show resolved Hide resolved
src/repr/src/adt/range.rs Outdated Show resolved Hide resolved
src/repr/Cargo.toml Outdated Show resolved Hide resolved
src/repr/src/row.rs Outdated Show resolved Hide resolved
src/repr/src/row.rs Outdated Show resolved Hide resolved
src/repr/src/row.rs Outdated Show resolved Hide resolved
src/repr/src/row.rs Outdated Show resolved Hide resolved
src/repr/src/adt/range.rs Outdated Show resolved Hide resolved
src/repr/src/adt/range.rs Outdated Show resolved Hide resolved
src/repr/src/adt/range.rs Outdated Show resolved Hide resolved
src/repr/src/adt/range.rs Outdated Show resolved Hide resolved
src/repr/src/adt/range.rs Outdated Show resolved Hide resolved
src/repr/src/row.rs Outdated Show resolved Hide resolved
src/repr/src/row.rs Outdated Show resolved Hide resolved
Comment on lines 2264 to 2268
// This essentially tests the encoding we'll need for non-partition
// reclocking data.
(None, Some(Datum::Null), "(,null)"),
(Some((Datum::Null, true)), None, "[null,)"),
(Some((Datum::Null, false)), None, "(null,)"),
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused about this! PostgreSQL doesn't support null as a range boundary. It seems like we shouldn't either? Do we need this for reclocking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, unfortunately we need this for reclocking, or rather, this is the most sensible value to use for PartitionId::None in reclocking. The value never gets surfaced or returned to users, so permitting it "back here" seemed fine. We could use some other magical value, but this seemed the most semantic.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, weird, ok. My specific concern is that NULL is used to mean "infinity" in certain contexts in PostgreSQL ranges

benesch=# select int4range(NULL, 1);
 int4range 
-----------
 (,1)
(1 row)

but as long as this is internal only it's probably fine! Why doesn't this ever get exposed to users? Does the reclocking relation just not expose the partition column for source types that don't have meaningful partitions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dug into this and it's possible we don't need this null-supporting feature. I'll add the panics on Datum::Null back in and can remove them if native timestamp reclocking turns out to need them.

src/repr/src/row.rs Outdated Show resolved Hide resolved
src/repr/src/row.rs Outdated Show resolved Hide resolved
@benesch
Copy link
Member

benesch commented Nov 29, 2022

Exciting to see this come together so quickly, Sean!

@sploiselle sploiselle force-pushed the range-datum branch 2 times, most recently from 1dd8d73 to 9b5d234 Compare November 30, 2022 20:06
@sploiselle
Copy link
Contributor Author

@benesch Believe I addressed all comments; PTAL.

Copy link
Member

@benesch benesch left a comment

Choose a reason for hiding this comment

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

Sorry for the relatively slow review! LGTM modulo the unused paste dep.

@@ -54,6 +55,7 @@ tracing-subscriber = { version = "0.3.16", default-features = false, optional =

[dev-dependencies]
criterion = { version = "0.4.0" }
paste = "1.0.9"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
paste = "1.0.9"

Comment on lines +180 to +181
/// Treats `Datum::Null` as an infinite bound (appropriate for PG
/// semantics), and all other `Datum`s as finite values.
Copy link
Member

Choose a reason for hiding this comment

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

This feels a little sketchy to me. I know it's what PostgreSQL does, but I'd almost prefer we do it in the one spot that PostgreSQL does it (range constructors, I think?) and nowhere else? But, idk, it's hard to know without seeing the rest of the code. No strong feels for the moment!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah--I think this API will shift as we build out SQL support for range types, but want to merge as is for sake convenience when building out the reclock migration.

@sploiselle sploiselle enabled auto-merge (rebase) December 5, 2022 19:50
@sploiselle sploiselle merged commit 1b568fd into MaterializeInc:main Dec 5, 2022
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