Skip to content

Conversation

caicancai
Copy link
Member

Which issue does this PR close?

Contrast with the memory_catalog_dereg_nonempty_schema test

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the core Core DataFusion crate label Aug 24, 2025
@caicancai
Copy link
Member Author

caicancai commented Aug 26, 2025

@alamb Can you help me take a look if you have time? I just added a test. If it doesn't work, I can close it. Thanks

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @caicancai 🙏


cat.register_schema("foo", schema.clone()).unwrap();
schema.deregister_table("t").unwrap();
assert!(cat.deregister_schema("foo", false).unwrap().is_some());
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this just follows the pattern of the existing tests in this module, so that is good

I think a better pattern for checking errors is to verify that the error is actually the error that is expected (to make sure it isn't an error in the test setup, for example).

Something like

Suggested change
assert!(cat.deregister_schema("foo", false).unwrap().is_some());
let err = cat.deregister_schema("foo", false).unwrap_err().to_string();
assert!(err.contains("expected error message"), "Can't find expected in {err}"));

That would be a nice follow on PR

Copy link
Member Author

@caicancai caicancai Aug 26, 2025

Choose a reason for hiding this comment

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

@alamb Thanks for the suggestion, but the above code will report an error

called Result::unwrap_err()on anOk value: Some(MemorySchemaProvider { tables: {} })

Copy link
Member Author

Choose a reason for hiding this comment

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

And referring to other tests, they are all written in a similar way, assert!(cat.deregister_schema("foo", false).unwrap().is_some()); Maybe it would be better to keep the original writing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants