-
Notifications
You must be signed in to change notification settings - Fork 64
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
feat!(ffi): remove visit_snapshot_schema
, add logical_schema
#709
feat!(ffi): remove visit_snapshot_schema
, add logical_schema
#709
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #709 +/- ##
==========================================
+ Coverage 84.35% 84.36% +0.01%
==========================================
Files 75 75
Lines 17657 17654 -3
Branches 17657 17654 -3
==========================================
Hits 14894 14894
+ Misses 2053 2050 -3
Partials 710 710 ☔ View full report in Codecov by Sentry. |
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.
LGTM. Couple side notes for tracking/follow-up.
@@ -98,6 +98,7 @@ impl Snapshot { | |||
} | |||
|
|||
/// Table [`Schema`] at this `Snapshot`s version. | |||
// TODO should this return SchemaRef? |
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.
Yes. It's already a SchemaRef
under the hood, and schemas can be quite large (i.e. tables with 10k columns)
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.
Similar story for the global read schema, I think
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.
/// | ||
/// Caller is responsible for passing a valid snapshot handle. | ||
#[no_mangle] | ||
pub unsafe extern "C" fn logical_schema(snapshot: Handle<SharedSnapshot>) -> Handle<SharedSchema> { |
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.
Ah! So logical_schema
extracts a schema from the snapshot, which can then be visited in the same way as the scan schema?
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.
aside: Eventually the logical schema the engine should see has been filtered to remove internal Delta properties, hidden columns (not currently a thing), etc. But then we have three schema types, and logical/physical do make sense already. Maybe the engine should see a "clean" schema or a "public" schema or something?
Or maybe this is the right function for that, and we just need to eventually add the necessary filtering here, instead of returning the "raw" snapshot schema?
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 maybe this is the right function for that, and we just need to eventually add the necessary filtering here, instead of returning the "raw" snapshot schema?
yea was thinking to keep this as the 'public-facing' snapshot schema. not sure if you think we should keep the name logical_schema
still or just snapshot_schema
? WDYT?
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.
This feels like a C way of doing snapshot.logical_schema()
vs snapshot.snapshot_schema()
. I prefer logical schema cuz snapshot_schema feels redundant.
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.
Besides the nits, this LGTM
What changes are proposed in this pull request?
This PR removes the old
visit_snapshot_schema
introduced in #683 - we should just go ahead and do the 'right thing' with having avisit_schema
(introduced in the other PR) and alogical_schema()
function (added here) in order to facilitate visiting the snapshot schema. Additionally I've moved the schema-related things up fromscan
module to top-level in ffi crate. Exact changes listed below; this PR updates tests/examples to leverage the new changes.This PR affects the following public APIs
visit_snapshot_schema()
APIlogical_schema(snapshot)
API so you can get the schema of a snapshot and use thevisit_schema
directlyfree_global_read_schema
to justfree_schema
SharedSchema
andfree_schema
up frommod scan
into top-levelffi
crate.How was this change tested?
existing UT