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.
feat:
Snapshot::try_new_from()
API #549New 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
feat:
Snapshot::try_new_from()
API #549Changes from 3 commits
f8bc074
3d37288
5480711
2686fb3
0daf1e9
692c9d5
f18e380
8d3357b
3bf3d67
453db1b
ce31322
f1578fb
ee61b75
fea0f76
81f61ae
7b0bd1c
691b23a
27c4a95
66e44d2
46ab944
5a582d6
592667b
75b6178
5cdde76
a94ddef
e8e327d
d5bcb67
be88b88
d396953
6e49bc2
032d72b
cb06927
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
What happens if the table has not changed? I somehow doubt
LogSegment::try_new
would like the empty file listing that results?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.
New
EmptyLogSegment
error that we can explicitly leverage (instead of having to change LogSegment semantics). I just dislike it beingpub
... see other comment above.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.
nit
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.
(or, just do that at the one call site, instead of defining a helper at all)
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.
yea realized probably not necessary, though I've kept the 'not is_empty()` since it's a vec
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.
Just to clarify, is this api only for versions later than the existing snapshot?
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.
yep for now proposing that we allow old snapshot but just return a new snapshot (no incrementalization) maybe
warn!
in that case? or i suppose we could disallow that..?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 any valid scenario where a caller could legitimately pass a newer snapshot than the one they're asking for? I guess time travel? But if they know they're time traveling why would they pass a newer snapshot in the first place?
Either way, we should publicly document whether a too-new starting snapshot is an error or merely a useless hint, so callers don't have to wonder.
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.
I can't think of any optimization that's available (let alone useful) if the caller passes in a new snapshot as the hint.
If that's true, then the question is: do we prohibit this behavior or just let it degenerate to the usual try_new the client should have done anyways?
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.
I would vote for returning an error in that case. It's unlikely the engine meant to get into that situation, so let's let them know they are doing something wrong
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.
updated to be an error now! i agree :)
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.
Tiny nit: I'd put this one first?
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.
Actually, I wonder if a match is really that helpful here, especially given that
LogSegment::for_versions
needs to handle the no-change case?Avoids the indirection and complexity of building a suffix log segment... but then we don't have an easy way to do the incremental P&M :(
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.
I played around with this some and refactored. critically, I'm still leveraging a LogSegment, but we have a new Error::EmptyLogSegment that we can specifically check for. I like the idea of (1) still using LogSegment and (2) having this error capture the empty case without having to modify semantics of LogSegment. BUT i dislike having to introduce a new
pub Error
variant. I didn't do the leg work to have a private error here - wanted to gather some feedback on overall approach firstThere 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.
Given that we're "supporting" some table features (like check constraints) only if not actually used... I think we also need to
ensure_read_supported
if metadata changes?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.
Actually our
ensure_read_supported
only depends on the protocol right now it looks like. We haveTableConfiguration.ensure_write_supported
which is a function ofProtocol
andMetadata
but we don't yet have that for 'read supported' - I wonder if we should go ahead and introduce that abstraction and for now just pass through to protocol.ensure_read_supported?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.
Oh, because column constraints are only a writer feature... do we not have any reader-writer features whose validity checks depend on metadata? Seems like column mapping needs to validate the schema annotations for example?
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.
not that I can tell: even for col mapping we just check that the feature is enabled to say that 'reads are supported' then, I think if there is incorrect schema annotations it would fail downstream.
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.
I'm pretty sure that validation happens in the
TableConfiguration
constructor? At least, that's where we originally planned to put it.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.
yep you're right - my mistake, lol i already included that in the new code (just forgot about it oops)
in both
TableConfiguration::try_new
andtry_new_from
(new code) we do a protocol.ensure_read_supported and avalidate_schema_column_mapping
- I wonder if we could do better here by modifying the constructor so that we can (1) have someone upstream do the parsing leg work and (2) leverage the constructor directly intry_new_from
?