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

Clean up inspect-table and add Cdc action support #527

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

scovich
Copy link
Collaborator

@scovich scovich commented Nov 22, 2024

What changes are proposed in this pull request?

The inspect-table example was brittle -- sensitive to field order and requiring a lot of manual fiddlery to add a new action -- and did not have support for the Cdc action.

Rework the code to be simpler and more flexible, and take advantage of that to add Cdc support.

How was this change tested?

Ran it on a table.

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.31%. Comparing base (d146b80) to head (7132846).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #527   +/-   ##
=======================================
  Coverage   80.31%   80.31%           
=======================================
  Files          62       62           
  Lines       13541    13541           
  Branches    13541    13541           
=======================================
  Hits        10876    10876           
  Misses       2106     2106           
  Partials      559      559           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Collaborator

@zachschuermann zachschuermann left a comment

Choose a reason for hiding this comment

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

LGTM

&getters[cdc_start..cdc_end],
)?)
} else {
// TODO: Add CommitInfo support (tricky because all fields are optional)
Copy link
Collaborator

Choose a reason for hiding this comment

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

made #528 for commit info support

let mut protocol_offset = 0;
let mut metadata_offset = 0;
let mut set_transaction_offset = 0;
fn new(log_schema: &'static SchemaRef) -> LogVisitor {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason for SchemaRef to be static?

Copy link
Collaborator Author

@scovich scovich Nov 22, 2024

Choose a reason for hiding this comment

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

Because rust is a bit silly, and you can't probe a HashMap<String, _> with &str (there's a Borrow<str> for String but no Borrow<&str> for String). So I'm storing HashMap<&'static str, _> instead, to avoid allocating a string for every map probe and/or adding a lifetime to the enclosing struct. I hit a similar issue with ColumnName btw, but could solve that one by defining a suitable Borrow (can do that since it's a local trait).

Copy link
Collaborator

Choose a reason for hiding this comment

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

there's a Borrow for String but no Borrow<&str> for String

wow you're right that is silly. TIL the difference between str and &str 👍

to avoid allocating a string for every map probe and/or adding a lifetime to the enclosing struct

that makes sense.

can do that since it's a local trait

And we can't do this because Borrow is a foreign trait, and SchemaRef is a foreign struct (from inspect-table's perspective). While in the example, ColumnName was at least local.

Thanks @scovich!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Update: Turns out if I pass e.g. offsets[ADD_NAME] instead of offsets[&ADD_NAME] then it works!

Copy link
Collaborator

@OussamaSaoudi-db OussamaSaoudi-db left a comment

Choose a reason for hiding this comment

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

LGTM, just had that question on 'static lifetime

@scovich scovich merged commit 2a95393 into delta-io:main Nov 22, 2024
20 checks passed
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